コード例 #1
0
ファイル: SecurityManager.cs プロジェクト: 0xjocosta/SIRS
        public SecurityManager(RSAParameters pcPubKey, byte[] Kdigest)
        {
            Helper = new SecurityManagerHelper();
            RSAManager RSAKeys = new RSAManager();

            Helper.SavePairKey(RSAKeys.PubKey, RSAKeys.PrivKey);
            Helper.SavePcPublicKey(pcPubKey);
            Helper.SaveDigestKey(Kdigest);
        }
コード例 #2
0
ファイル: SecurityManager.cs プロジェクト: 0xjocosta/SIRS
        public string DecodeAndDecryptMessage(string msg)
        {
            RSAManager RSAKeys = new RSAManager(Helper.GetPublicKey().RSAParameters, Helper.GetPrivateKey());
            Message    message = AuthenticateMessage(msg);

            //Decipher symm key to decipher the content
            string      keyToDecipher = RSAKeys.Decrypt(message.KeyToDecipher);
            KeyDecipher keyDecipher   = JsonConvert.DeserializeObject <KeyDecipher>(keyToDecipher);

            //Decipher content
            AesManager aesManager = new AesManager();

            aesManager.Update(keyDecipher.Key, keyDecipher.IV);

            byte[] content = JsonConvert.DeserializeObject <byte[]>(message.Cryptotext);
            string Content = aesManager.DecryptStringFromBytes_Aes(content);

            JsonFreshMessage jsonFreshMessage = JsonConvert.DeserializeObject <JsonFreshMessage>(Content);

            VerifyNonce(jsonFreshMessage.Nonce);

            return(jsonFreshMessage.Message);
        }
コード例 #3
0
ファイル: SecurityManager.cs プロジェクト: 0xjocosta/SIRS
        public string JsonMessage(string msg)
        {
            RSAManager RSAKeys    = new RSAManager(Helper.GetPcPublicKey());
            AesManager aesManager = new AesManager();

            //Cipher content with the symmetric key
            byte[] bytes      = aesManager.EncryptStringToBytes_Aes(msg);
            string cipherText = JsonConvert.SerializeObject(bytes);

            //Cipher the symmetric key with pub key
            KeyDecipher keyDecipher = new KeyDecipher(aesManager.Key, aesManager.InitVect);
            string      KeyDecipher = JsonConvert.SerializeObject(keyDecipher);
            string      cipheredKey = RSAKeys.Encrypt(KeyDecipher);

            //The cipherText and cipherKey
            Message message = new Message(cipherText, cipheredKey);
            string  Message = JsonConvert.SerializeObject(message);

            //Digest the message
            HMACManager DigestKey = new HMACManager(Helper.GetDigestKey());

            return(JsonConvert.SerializeObject(new JsonCryptoDigestMessage(Message, DigestKey.Encode(Message))));
        }
コード例 #4
0
ファイル: SecurityManager.cs プロジェクト: 0xjocosta/SIRS
        public string DecryptContentFromHost(string content)
        {
            RSAManager RSAKeys = new RSAManager(Helper.GetPublicKey().RSAParameters, Helper.GetPrivateKey());

            return(RSAKeys.Decrypt(content));
        }