Ejemplo n.º 1
0
 public SpanContainer(CTR_DRBG_CTX state, byte txSequenceNumber, byte rxSequenceNumber, byte[] nonce)
     : this(txSequenceNumber, rxSequenceNumber)
 {
     _state    = state;
     SpanState = SpanStates.Span;
     Array.Copy(nonce, _span, 16);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets 16 bytes of pseudo random data
        /// </summary>
        /// <returns>16 bytes of pseudo random data</returns>
        public byte[] GetRandomData()
        {
            var ctx             = new CTR_DRBG_CTX();
            var personalization = new byte[SecurityS2Utils.PERSONALIZATION_SIZE];

            SecurityS2Utils.AesCtrDrbgInstantiate(ref ctx, GetEntropyInput(), personalization);
            var ret = new byte[SecurityS2Utils.KEY_SIZE];

            SecurityS2Utils.AesCtrDrbgGenerate(ref ctx, ret);
            return(ret);
        }
Ejemplo n.º 3
0
 public static int NextNonceGenerate(ref CTR_DRBG_CTX ctx, byte[] rand)
 {
     lock (_syncObj)
     {
         if (Is64Bit)
         {
             return(NextNonceGenerate_64(ref ctx, rand));
         }
         else
         {
             return(NextNonceGenerate_32(ref ctx, rand));
         }
     }
 }
Ejemplo n.º 4
0
 public static void NextNonceInstantiate(ref CTR_DRBG_CTX ctx, byte[] ei_sender, byte[] ei_receiver, byte[] personalization)
 {
     lock (_syncObj)
     {
         if (Is64Bit)
         {
             NextNonceInstantiate_64(ref ctx, ei_sender, ei_receiver, personalization);
         }
         else
         {
             NextNonceInstantiate_32(ref ctx, ei_sender, ei_receiver, personalization);
         }
     }
 }
Ejemplo n.º 5
0
 public static void AesCtrDrbgInstantiate(ref CTR_DRBG_CTX ctx, byte[] entropy_input, byte[] personalization)
 {
     lock (_syncObj)
     {
         if (Is64Bit)
         {
             AesCtrDrbgInstantiate_64(ref ctx, entropy_input, personalization);
         }
         else
         {
             AesCtrDrbgInstantiate_32(ref ctx, entropy_input, personalization);
         }
     }
 }
Ejemplo n.º 6
0
 private extern static int NextNonceGenerate_64(ref CTR_DRBG_CTX ctx,
                                                [MarshalAs(UnmanagedType.LPArray)] byte[] rand);
Ejemplo n.º 7
0
 private extern static void NextNonceInstantiate_64(ref CTR_DRBG_CTX ctx,
                                                    [In, MarshalAs(UnmanagedType.LPArray, SizeConst = SecurityS2Utils.NONCE_SIZE)] byte[] ei_sender,
                                                    [In, MarshalAs(UnmanagedType.LPArray, SizeConst = SecurityS2Utils.NONCE_SIZE)] byte[] ei_receiver,
                                                    [In, MarshalAs(UnmanagedType.LPArray, SizeConst = SecurityS2Utils.PERSONALIZATION_SIZE)] byte[] personalization);
Ejemplo n.º 8
0
 private extern static int AesCtrDrbgGenerate_32(ref CTR_DRBG_CTX ctx,
                                                 [MarshalAs(UnmanagedType.LPArray)] byte[] rand);
Ejemplo n.º 9
0
 private extern static void AesCtrDrbgInstantiate_32(ref CTR_DRBG_CTX ctx,
                                                     [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 32)] byte[] entropy_input,
                                                     [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 32)] byte[] personalization);