init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using Org.BouncyCastle.Asn1.Cms;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Cms;
public class KekRecipientInformation : RecipientInformation
{
private KekRecipientInfo info;
internal KekRecipientInformation(KekRecipientInfo info, CmsSecureReadable secureReadable)
: base(info.KeyEncryptionAlgorithm, secureReadable)
{
this.info = info;
rid = new RecipientID();
KekIdentifier kekID = info.KekID;
rid.KeyIdentifier = kekID.KeyIdentifier.GetOctets();
}
public override CmsTypedStream GetContentStream(ICipherParameters key)
{
try
{
byte[] octets = info.EncryptedKey.GetOctets();
IWrapper wrapper = WrapperUtilities.GetWrapper(keyEncAlg.Algorithm.Id);
wrapper.Init(forWrapping: false, key);
KeyParameter sKey = ParameterUtilities.CreateKeyParameter(GetContentAlgorithmName(), wrapper.Unwrap(octets, 0, octets.Length));
return GetContentFromSessionKey(sKey);
}
catch (SecurityUtilityException e)
{
throw new CmsException("couldn't create cipher.", e);
}
catch (InvalidKeyException e2)
{
throw new CmsException("key invalid in message.", e2);
}
}
}