Exemple #1
0
        protected internal void CreateSetSessionKeyRequest(out AesKeyVectorPair kvp, out SetSessionKeyRequest request)
        {
            kvp = new AesKeyVectorPair();
            string keyCipher     = kvp.Key.EncryptWithPublicKey(SessionInfo.PublicKey, Encoding.UTF8);
            string keyHash       = kvp.Key.Sha256();
            string keyHashCipher = keyHash.EncryptWithPublicKey(SessionInfo.PublicKey, Encoding.UTF8);
            string ivCipher      = kvp.IV.EncryptWithPublicKey(SessionInfo.PublicKey, Encoding.UTF8);
            string ivHash        = kvp.IV.Sha256();
            string ivHashCipher  = ivHash.EncryptWithPublicKey(SessionInfo.PublicKey, Encoding.UTF8);

            request = new SetSessionKeyRequest(keyCipher, keyHashCipher, ivCipher, ivHashCipher);
        }
Exemple #2
0
        public void SetSymmetricKey(SetSessionKeyRequest request)
        {
            PlainSymmetricKey = DecryptWithPrivateKey(request.KeyCipher, request.GetEngine());
            string passwordHash = DecryptWithPrivateKey(request.KeyHashCipher, request.GetEngine());

            Expect.AreEqual(PlainSymmetricKey.Sha256(), passwordHash, "Key hash check failed");
            PlainSymmetricIV = DecryptWithPrivateKey(request.IVCipher, request.GetEngine());
            string ivHash = DecryptWithPrivateKey(request.IVHashCipher, request.GetEngine());

            Expect.AreEqual(PlainSymmetricIV.Sha256(), ivHash, "IV hash check failed");
            this.Save();
        }
Exemple #3
0
        public SecureChannelMessage SetSessionKey(SetSessionKeyRequest request)
        {
            SecureChannelMessage result = new SecureChannelMessage(true);

            try
            {
                SecureSession session = SecureSession.Get(HttpContext);
                session.SetSymmetricKey(request);
            }
            catch (Exception ex)
            {
                result = new SecureChannelMessage(ex);
            }

            return(result);
        }