本文整理匯總了C#中Org.BouncyCastle.Asn1.X509.AlgorithmIdentifier.GetEncoded方法的典型用法代碼示例。如果您正苦於以下問題:C# AlgorithmIdentifier.GetEncoded方法的具體用法?C# AlgorithmIdentifier.GetEncoded怎麽用?C# AlgorithmIdentifier.GetEncoded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Org.BouncyCastle.Asn1.X509.AlgorithmIdentifier
的用法示例。
在下文中一共展示了AlgorithmIdentifier.GetEncoded方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Open
protected Stream Open(
Stream outStream,
string encryptionOid,
KeyParameter encKey,
Asn1Encodable asn1Params,
Asn1EncodableVector recipientInfos)
{
Asn1Object asn1Object;
ICipherParameters cipherParameters;
if (asn1Params != null)
{
asn1Object = asn1Params.ToAsn1Object();
cipherParameters = ParameterUtilities.GetCipherParameters(
encryptionOid, encKey, asn1Object);
}
else
{
asn1Object = DerNull.Instance;
cipherParameters = encKey;
}
try
{
AlgorithmIdentifier encAlgId = new AlgorithmIdentifier(
new DerObjectIdentifier(encryptionOid),
asn1Object);
//
// ContentInfo
//
BerSequenceGenerator cGen = new BerSequenceGenerator(outStream);
cGen.AddObject(CmsObjectIdentifiers.EnvelopedData);
//
// Encrypted Data
//
BerSequenceGenerator envGen = new BerSequenceGenerator(
cGen.GetRawOutputStream(), 0, true);
envGen.AddObject(this.Version);
DerSet derSet = _berEncodeRecipientSet
? new BerSet(recipientInfos)
: new DerSet(recipientInfos);
byte[] derSetEncoding = derSet.GetEncoded();
envGen.GetRawOutputStream().Write(derSetEncoding, 0, derSetEncoding.Length);
IBufferedCipher cipher = CipherUtilities.GetCipher(encryptionOid);
cipher.Init(true, cipherParameters);
BerSequenceGenerator eiGen = new BerSequenceGenerator(
envGen.GetRawOutputStream());
eiGen.AddObject(PkcsObjectIdentifiers.Data);
byte[] tmp = encAlgId.GetEncoded();
eiGen.GetRawOutputStream().Write(tmp, 0, tmp.Length);
BerOctetStringGenerator octGen = new BerOctetStringGenerator(
eiGen.GetRawOutputStream(), 0, false);
Stream octetOutputStream = _bufferSize != 0
? octGen.GetOctetOutputStream(new byte[_bufferSize])
: octGen.GetOctetOutputStream();
CipherStream cOut = new CipherStream(octetOutputStream, null, cipher);
return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
catch (SecurityUtilityException e)
{
throw new CmsException("couldn't create cipher.", e);
}
catch (InvalidKeyException e)
{
throw new CmsException("key invalid in message.", e);
}
catch (IOException e)
{
throw new CmsException("exception decoding algorithm parameters.", e);
}
}