From 1be4f6e20c4ee1d973fd0d831d057813f9c2930e Mon Sep 17 00:00:00 2001
From: Kyle Spearrin <kyle.spearrin@gmail.com>
Date: Fri, 21 Apr 2017 13:40:29 -0400
Subject: [PATCH] add support for rsa oaep sha1 enc type

---
 src/App/Enums/EncryptionType.cs   |  3 ++-
 src/App/Models/CipherString.cs    |  3 ++-
 src/App/Services/CryptoService.cs | 13 ++++++++++---
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/App/Enums/EncryptionType.cs b/src/App/Enums/EncryptionType.cs
index 9a808d2da..885d873d5 100644
--- a/src/App/Enums/EncryptionType.cs
+++ b/src/App/Enums/EncryptionType.cs
@@ -5,6 +5,7 @@
         AesCbc256_B64 = 0,
         AesCbc128_HmacSha256_B64 = 1,
         AesCbc256_HmacSha256_B64 = 2,
-        RsaOaep_Sha256_B64 = 3
+        Rsa2048_OaepSha256_B64 = 3,
+        Rsa2048_OaepSha1_B64 = 4
     }
 }
diff --git a/src/App/Models/CipherString.cs b/src/App/Models/CipherString.cs
index 37030b54b..2de058404 100644
--- a/src/App/Models/CipherString.cs
+++ b/src/App/Models/CipherString.cs
@@ -55,7 +55,8 @@ namespace Bit.App.Models
                     CipherText = encPieces[1];
                     Mac = encPieces[2];
                     break;
-                case EncryptionType.RsaOaep_Sha256_B64:
+                case EncryptionType.Rsa2048_OaepSha256_B64:
+                case EncryptionType.Rsa2048_OaepSha1_B64:
                     if(encPieces.Length != 1)
                     {
                         throw new ArgumentException("Malformed encPieces.");
diff --git a/src/App/Services/CryptoService.cs b/src/App/Services/CryptoService.cs
index 115b3cc88..974663e7c 100644
--- a/src/App/Services/CryptoService.cs
+++ b/src/App/Services/CryptoService.cs
@@ -350,12 +350,19 @@ namespace Bit.App.Services
                 throw new ArgumentNullException(nameof(privateKey));
             }
 
-            if(encyptedValue.EncryptionType != EncryptionType.RsaOaep_Sha256_B64)
+            IAsymmetricKeyAlgorithmProvider provider = null;
+            switch(encyptedValue.EncryptionType)
             {
-                throw new ArgumentException("encType unavailable.");
+                case EncryptionType.Rsa2048_OaepSha256_B64:
+                    provider = WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithm.RsaOaepSha256);
+                    break;
+                case EncryptionType.Rsa2048_OaepSha1_B64:
+                    provider = WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithm.RsaOaepSha1);
+                    break;
+                default:
+                    throw new ArgumentException("EncryptionType unavailable.");
             }
 
-            var provider = WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithm.RsaOaepSha256);
             var cryptoKey = provider.ImportKeyPair(privateKey, CryptographicPrivateKeyBlobType.Pkcs8RawPrivateKeyInfo);
             var decryptedBytes = WinRTCrypto.CryptographicEngine.Decrypt(cryptoKey, encyptedValue.CipherTextBytes);
             return decryptedBytes;