summary refs log tree commit diff
path: root/crypto/src/pqc/crypto/frodo/FrodoParameters.cs
blob: 69d3e5de6d7383593ce80f085e07a4b0293b4367 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;

namespace Org.BouncyCastle.Pqc.Crypto.Frodo
{
    public sealed class FrodoParameters
        : ICipherParameters
    {
        private static short[] cdf_table640  = {4643, 13363, 20579, 25843, 29227, 31145, 32103, 32525, 32689, 32745, 32762, 32766, 32767};
        private static short[] cdf_table976  = {5638, 15915, 23689, 28571, 31116, 32217, 32613, 32731, 32760, 32766, 32767};
        private static short[] cdf_table1344 = {9142, 23462, 30338, 32361, 32725, 32765, 32767};

        public static FrodoParameters frodokem19888r3 = new FrodoParameters("frodokem19888", 640, 15, 2, cdf_table640, new ShakeDigest(128), new FrodoMatrixGenerator.Aes128MatrixGenerator(640, (1<<15)));
        public static FrodoParameters frodokem19888shaker3 = new FrodoParameters("frodokem19888shake", 640, 15, 2, cdf_table640, new ShakeDigest(128), new FrodoMatrixGenerator.Shake128MatrixGenerator(640, (1<<15)));

        public static FrodoParameters frodokem31296r3 = new FrodoParameters("frodokem31296", 976, 16, 3, cdf_table976, new ShakeDigest(256), new FrodoMatrixGenerator.Aes128MatrixGenerator(976, (1<<16)));
        public static FrodoParameters frodokem31296shaker3 = new FrodoParameters("frodokem31296shake", 976, 16, 3, cdf_table976, new ShakeDigest(256), new FrodoMatrixGenerator.Shake128MatrixGenerator(976, (1<<16)));

        public static FrodoParameters frodokem43088r3 = new FrodoParameters("frodokem43088", 1344, 16, 4, cdf_table1344, new ShakeDigest(256), new FrodoMatrixGenerator.Aes128MatrixGenerator(1344, (1<<16)));
        public static FrodoParameters frodokem43088shaker3 = new FrodoParameters("frodokem43088shake", 1344, 16, 4, cdf_table1344, new ShakeDigest(256), new FrodoMatrixGenerator.Shake128MatrixGenerator(1344, (1<<16)));

        private string name;
        private int n;
        private int d;
        private int b;
        private short[] cdf_table;
        private IDigest digest;
        private FrodoMatrixGenerator mGen;
        private int defaultKeySize;
        private FrodoEngine engine;

        public FrodoParameters(string name, int n, int d, int b, short[] cdf_table, IDigest digest,
            FrodoMatrixGenerator mGen)
        {
            this.name = name;
            this.n = n;
            this.d = d;
            this.b = b;
            this.cdf_table = cdf_table;
            this.digest = digest;
            this.mGen = mGen;
            this.defaultKeySize = B * FrodoEngine.nbar * FrodoEngine.nbar;
            this.engine = new FrodoEngine(n, d, b, cdf_table, digest, mGen);
        }

        public FrodoEngine Engine => engine;

        public int N => n;

        public string Name => name;

        public int D => d;

        public int B => b;

        public short[] CdfTable => cdf_table;

        public IDigest Digest => digest;

        public int DefaultKeySize => defaultKeySize;

        public FrodoMatrixGenerator MGen => mGen;
    }
}