blob: 642e29f2d9ba53129c9f0cc41fadc2494745572e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
using System.IO;
using Org.BouncyCastle.Utilities.Encoders;
namespace Org.BouncyCastle.Pqc.Crypto.Lms
{
public class LMSVectorUtils
{
public static byte[] ExtractPrefixedBytes(string vectorFromRFC)
{
MemoryStream bos = new MemoryStream();
byte[] hexByte;
foreach (string line in vectorFromRFC.Split('\n'))
{
int start = line.IndexOf('$');
if (start > -1)
{
++start;
int end = line.IndexOf('#');
string hex;
if (end < 0)
{
hex = line.Substring(start).Trim();
}
else
{
hex = line.Substring(start, end - start).Trim();
}
hexByte = Hex.Decode(hex);
bos.Write(hexByte, 0, hexByte.Length);
}
}
return bos.ToArray();
}
}
}
|