Example #1
0
 public void Create(LmsAlgorithmType[] lmsType, LmotsAlgorithmType lmotsType)
 {
     _hssTree = new HssNode[lmsType.Length];
     for (int i = 0; i < lmsType.Length; i++)
     {
         _hssTree[i] = new HssNode(lmsType[i], lmotsType);
     }
 }
Example #2
0
            /// <summary>
            /// Take an array of strings and fill in the private key from that
            /// Fields in order are:  LMS type, LMOTS type, Seed, Q, Identifier
            /// </summary>
            /// <param name="input"></param>
            /// <param name="offset"></param>
            public LmsKey(string[] input, int offset)
            {
                _lmsType   = (LmsAlgorithmType)Int32.Parse(input[offset]);
                _lmotsType = (LmotsAlgorithmType)Int32.Parse(input[offset + 1]);
                _seed      = StringToByteArray(input[offset + 2]);
                LeafNumber = Int32.Parse(input[offset + 3]);
                Identifier = StringToByteArray(input[offset + 4]);

                BuildFromSeed(_seed);
            }
Example #3
0
            private static UInt16 Checksum(byte[] Q, int w, LmotsAlgorithmType lmotsType)
            {
                UInt16 sum = 0;
                UInt16 max = (UInt16)((1 << w) - 1);

                for (int i = 0; i < (Q.Length * 8 / w); i += 1)
                {
                    sum += (UInt16)(max - Coef(Q, i, w));
                }

                return((UInt16)(sum << Constants.Values[(int)lmotsType].ls));
            }
Example #4
0
            public LmsKey(LmsAlgorithmType lmsTypeIn, LmotsAlgorithmType lmotsTypeIn)
            {
                _lmsType   = lmsTypeIn;
                _lmotsType = lmotsTypeIn;
                Identifier = new byte[16];

                SecureRandom rng = Message.GetPRNG();

                rng.NextBytes(Identifier, 0, 16);

                _seed = new byte[M];
                rng.NextBytes(_seed, 0, _seed.Length);
                BuildFromSeed(_seed);
            }
Example #5
0
 public HssNode(LmsAlgorithmType lmsType, LmotsAlgorithmType lmotsType)
 {
     privateKey = new LmsKey(lmsType, lmotsType);
 }