diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-19 14:55:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-19 14:55:27 +0700 |
commit | 931946b3426d1c13c30c09aef87102a129a4a04a (patch) | |
tree | 64686c44a0b5d22f50e39aec508e48d2e5c20f18 /crypto/src/cms | |
parent | Asn1.Tsp updates from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-931946b3426d1c13c30c09aef87102a129a4a04a.tar.xz |
Refactoring in Cms
Diffstat (limited to 'crypto/src/cms')
-rw-r--r-- | crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs | 14 | ||||
-rw-r--r-- | crypto/src/cms/KeyAgreeRecipientInformation.cs | 10 |
2 files changed, 10 insertions, 14 deletions
diff --git a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs index 479aa50cb..97fbd115b 100644 --- a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs +++ b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs @@ -146,12 +146,10 @@ namespace Org.BouncyCastle.Cms new DerSequence(recipientEncryptedKeys))); } - private static OriginatorPublicKey CreateOriginatorPublicKey(AsymmetricKeyParameter publicKey) - { - SubjectPublicKeyInfo spki = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey); - return new OriginatorPublicKey( - new AlgorithmIdentifier(spki.AlgorithmID.Algorithm, DerNull.Instance), - spki.PublicKeyData.GetBytes()); - } - } + private static OriginatorPublicKey CreateOriginatorPublicKey(AsymmetricKeyParameter publicKey) => + CreateOriginatorPublicKey(SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey)); + + private static OriginatorPublicKey CreateOriginatorPublicKey(SubjectPublicKeyInfo originatorKeyInfo) => + new OriginatorPublicKey(originatorKeyInfo.AlgorithmID, originatorKeyInfo.PublicKeyData); + } } diff --git a/crypto/src/cms/KeyAgreeRecipientInformation.cs b/crypto/src/cms/KeyAgreeRecipientInformation.cs index cc1823cc6..32679803d 100644 --- a/crypto/src/cms/KeyAgreeRecipientInformation.cs +++ b/crypto/src/cms/KeyAgreeRecipientInformation.cs @@ -104,14 +104,12 @@ namespace Org.BouncyCastle.Cms return GetPublicKeyFromOriginatorID(origID); } - private AsymmetricKeyParameter GetPublicKeyFromOriginatorPublicKey( - AsymmetricKeyParameter receiverPrivateKey, - OriginatorPublicKey originatorPublicKey) + private AsymmetricKeyParameter GetPublicKeyFromOriginatorPublicKey(AsymmetricKeyParameter receiverPrivateKey, + OriginatorPublicKey originatorPublicKey) { PrivateKeyInfo privInfo = PrivateKeyInfoFactory.CreatePrivateKeyInfo(receiverPrivateKey); - SubjectPublicKeyInfo pubInfo = new SubjectPublicKeyInfo( - privInfo.PrivateKeyAlgorithm, - originatorPublicKey.PublicKey.GetBytes()); + SubjectPublicKeyInfo pubInfo = new SubjectPublicKeyInfo(privInfo.PrivateKeyAlgorithm, + originatorPublicKey.PublicKey); return PublicKeyFactory.CreateKey(pubInfo); } |