Exemplo n.º 1
0
        private static byte[] DecipherContent(string wrappedReceiptKey, string content, AsymmetricCipherKeyPair keyPair)
        {
            byte[] unwrappedKey = UnwrapKey(wrappedReceiptKey, keyPair);

            byte[]        contentBytes  = Conversion.Base64ToBytes(content);
            EncryptedData encryptedData = EncryptedData.Parser.ParseFrom(contentBytes);

            byte[] iv         = encryptedData.Iv.ToByteArray();
            byte[] cipherText = encryptedData.CipherText.ToByteArray();

            byte[] decipheredBytes = DecipherAes(unwrappedKey, iv, cipherText);
            return(decipheredBytes);
        }
Exemplo n.º 2
0
        public static AttributeList DecryptCurrentUserReceipt(string wrappedReceiptKey, string otherPartyProfile, AsymmetricCipherKeyPair keyPair)
        {
            byte[] unwrappedKey = UnwrapKey(wrappedReceiptKey, keyPair);

            byte[]        otherPartyProfileContentBytes = Conversion.Base64ToBytes(otherPartyProfile);
            EncryptedData encryptedData = EncryptedData.Parser.ParseFrom(otherPartyProfileContentBytes);

            byte[] iv         = encryptedData.Iv.ToByteArray();
            byte[] cipherText = encryptedData.CipherText.ToByteArray();

            byte[] decipheredBytes = DecipherAes(unwrappedKey, iv, cipherText);

            return(AttributeList.Parser.ParseFrom(decipheredBytes));
        }
Exemplo n.º 3
0
        private AttributeList DecryptCurrentUserReceipt(ReceiptDO receipt, AsymmetricCipherKeyPair keyPair)
        {
            byte[] unwrappedKey = UnwrapKey(receipt.wrapped_receipt_key, keyPair);

            byte[]        otherPartyProfileContentBytes = Conversion.Base64ToBytes(receipt.other_party_profile_content);
            EncryptedData encryptedData = EncryptedData.Parser.ParseFrom(otherPartyProfileContentBytes);

            byte[] iv         = encryptedData.Iv.ToByteArray();
            byte[] cipherText = encryptedData.CipherText.ToByteArray();

            byte[] decipheredBytes = CryptoEngine.DecipherAes(unwrappedKey, iv, cipherText);

            return(AttributeList.Parser.ParseFrom(decipheredBytes));
        }
Exemplo n.º 4
0
        public YotiAttributeValue(TypeEnum type, string data)
        {
            _type = type;

            switch (_type)
            {
            case TypeEnum.Jpeg:
            case TypeEnum.Png:
                _data = Conversion.Base64ToBytes(data);
                break;

            default:
                _data = Conversion.UtfToBytes(data);
                break;
            }
        }
Exemplo n.º 5
0
        internal static byte[] UnwrapKey(string wrappedKey, AsymmetricCipherKeyPair keyPair)
        {
            byte[] cipherBytes = Conversion.Base64ToBytes(wrappedKey);

            return(DecryptRsa(cipherBytes, keyPair));
        }
Exemplo n.º 6
0
        private byte[] UnwrapKey(string wrappedKey, AsymmetricCipherKeyPair keyPair)
        {
            byte[] cipherBytes = Conversion.Base64ToBytes(wrappedKey);

            return(CryptoEngine.DecryptRsa(cipherBytes, keyPair));
        }