コード例 #1
0
            private void AddEdchSessionInfo(byte[] si, ISecureRandom random)
            {
                ECDHPublicKeyParameters ephemeralPublicKey;

                var engine = new RFC6637ECDHEngine();
                engine.InitForEncryption(random, (ECDHPublicKeyParameters)_pubKey.GetKey(), _pubKey.GetFingerprint(), out ephemeralPublicKey);
                var encSession = engine.ProcessBlock(si, 0, si.Length);
                _data = new[]
                {
                    new BigInteger(1, ephemeralPublicKey.Q.GetEncoded()),
                };
                _extraData = encSession;
            }
コード例 #2
0
        private byte[] ProcessSymmetricKeyDataForEcdh(IPgpPrivateKey privKey, IList<IBigInteger> symmetricKeyData)
        {
            var encSymKey = symmetricKeyData[1].ToByteArrayUnsigned();
            var privateKey = (ECDHPrivateKeyParameters)privKey.Key;
            var publicKey = privateKey.PublicKeyParameters;
            var ephemeralKey = ECDHPublicKeyParameters.Create(symmetricKeyData[0], publicKey.PublicKeyParamSet, publicKey.HashAlgorithm, publicKey.SymmetricKeyAlgorithm);

            var engine = new RFC6637ECDHEngine();
            engine.InitForDecryption(privateKey, ephemeralKey);
            return engine.ProcessBlock(encSymKey, 0, encSymKey.Length);
        }