-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathPrimitives.cs
More file actions
37 lines (32 loc) · 764 Bytes
/
Primitives.cs
File metadata and controls
37 lines (32 loc) · 764 Bytes
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;
using System.Collections.Generic;
using System.Text;
namespace Waher.Security.PKCS
{
/// <summary>
/// Contains static functions used by different algorithms.
/// </summary>
public static class Primitives
{
/// <summary>
/// Concatenates a series of octet strings.
/// </summary>
/// <param name="OctetStrings">Octet strings to concatenate.</param>
/// <returns>Concatenated octet string.</returns>
public static byte[] CONCAT(params byte[][] OctetStrings)
{
int c = 0;
foreach (byte[] A in OctetStrings)
c += A.Length;
byte[] Result = new byte[c];
int i = 0;
foreach (byte[] A in OctetStrings)
{
c = A.Length;
Buffer.BlockCopy(A, 0, Result, i, c);
i += c;
}
return Result;
}
}
}