Exemple #1
0
        public Gost3410_2012_256CryptoServiceProvider(IntPtr hProvHandle, int keySpec)
        {
            _safeProvHandle = new SafeProvHandle(hProvHandle, true);
            _keySpec        = keySpec;

            LegalKeySizesValue = new KeySizes[] { new KeySizes(
                                                      GostConstants.GOST3410_2012_256KEY_SIZE, GostConstants.GOST3410_2012_256KEY_SIZE, 0) };
            _safeKeyHandle = CapiHelper.GetKeyPairHelper(
                CspAlgorithmType.Gost2012_256,
                keySpec,
                GostConstants.GOST3410_2012_256KEY_SIZE,
                _safeProvHandle);
            _hashImpl = Gost3411_2012_256.Create();
        }
 /// <summary>
 /// Retreives the key pair
 /// </summary>
 private void GetKeyPair()
 {
     if (_safeKeyHandle == null)
     {
         lock (this)
         {
             if (_safeKeyHandle == null)
             {
                 // We only attempt to generate a random key on desktop runtimes because the CoreCLR
                 // RSA surface area is limited to simply verifying signatures.  Since generating a
                 // random key to verify signatures will always lead to failure (unless we happend to
                 // win the lottery and randomly generate the signing key ...), there is no need
                 // to add this functionality to CoreCLR at this point.
                 CapiHelper.GetKeyPairHelper(CapiHelper.CspAlgorithmType.Rsa, _parameters,
                                             _randomKeyContainer, _keySize, ref _safeProvHandle, ref _safeKeyHandle);
             }
         }
     }
 }