Skip to content

Commit

Permalink
Added RSA disposal
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanayx committed Jul 4, 2024
1 parent 06496ee commit 36e5661
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Pulsar.Client/Crypto/MessageCrypto.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ type MessageEncryptor(keyNames: string seq, keyReader: ICryptoKeyReader) =
let loadPublicKey keyName =
let publicKeyInfo = keyReader.GetPublicKey keyName
let rsaPublicKey = parsePublicKey publicKeyInfo.Key
let rsa = RSA.Create()
rsa.ImportParameters rsaPublicKey
use rsa = RSA.Create(rsaPublicKey)
let encKey = rsa.Encrypt(symmetricKey.Export(KeyBlobFormat.RawSymmetricKey), RSAEncryptionPadding.OaepSHA1)
let encryptionKeys = EncryptionKey(keyName, encKey, publicKeyInfo.Metadata)
encryptionKeys
Expand Down Expand Up @@ -82,8 +81,7 @@ type MessageDecryptor(keyReader: ICryptoKeyReader) =
try
let privateKey = keyReader.GetPrivateKey(encryptionKey.Name, encryptionKey.Metadata)
let rsaPrivateKey = parsePrivateKey privateKey.Key
let rsa = RSA.Create()
rsa.ImportParameters(rsaPrivateKey)
use rsa = RSA.Create(rsaPrivateKey)
let keyBlob = rsa.Decrypt(encKey, RSAEncryptionPadding.OaepSHA1)
Some(encKey, keyBlob)
with ex ->
Expand Down

0 comments on commit 36e5661

Please sign in to comment.