public static PgpSecretKeyRing CopyWithNewPassword(PgpSecretKeyRing ring, char[] oldPassPhrase, char[] newPassPhrase, SymmetricKeyAlgorithmTag newEncAlgorithm, SecureRandom rand) { global::System.Collections.IList list = Platform.CreateArrayList(((global::System.Collections.ICollection)ring.keys).get_Count()); global::System.Collections.IEnumerator enumerator = ring.GetSecretKeys().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSecretKey pgpSecretKey = (PgpSecretKey)enumerator.get_Current(); if (pgpSecretKey.IsPrivateKeyEmpty) { list.Add((object)pgpSecretKey); } else { list.Add((object)PgpSecretKey.CopyWithNewPassword(pgpSecretKey, oldPassPhrase, newPassPhrase, newEncAlgorithm, rand)); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(new PgpSecretKeyRing(list, ring.extraPubKeys)); }
public void AddKeyTransRecipient(X509Certificate cert) { KeyTransRecipientInfoGenerator keyTransRecipientInfoGenerator = new KeyTransRecipientInfoGenerator(); keyTransRecipientInfoGenerator.RecipientCert = cert; recipientInfoGenerators.Add((object)keyTransRecipientInfoGenerator); }
private static PgpPublicKey AddCert(PgpPublicKey key, object id, PgpSignature certification) { PgpPublicKey pgpPublicKey = new PgpPublicKey(key); global::System.Collections.IList list = null; for (int i = 0; i != ((global::System.Collections.ICollection)pgpPublicKey.ids).get_Count(); i++) { if (id.Equals(pgpPublicKey.ids.get_Item(i))) { list = (global::System.Collections.IList)pgpPublicKey.idSigs.get_Item(i); } } if (list != null) { list.Add((object)certification); } else { list = Platform.CreateArrayList(); list.Add((object)certification); pgpPublicKey.ids.Add(id); pgpPublicKey.idTrusts.Add((object)null); pgpPublicKey.idSigs.Add((object)list); } return(pgpPublicKey); }
public void Add(params Asn1Encodable[] objs) { foreach (Asn1Encodable asn1Encodable in objs) { v.Add((object)asn1Encodable); } }
public void AddExtension(string oid, bool critical, byte[] value) { DerObjectIdentifier derObjectIdentifier = new DerObjectIdentifier(oid); extensions.set_Item((object)derObjectIdentifier, (object)new X509Extension(critical, new DerOctetString(value))); extOrdering.Add((object)derObjectIdentifier); }
public global::System.Collections.IEnumerable GetKeyRings(string userId, bool matchPartial, bool ignoreCase) { global::System.Collections.IList list = Platform.CreateArrayList(); if (ignoreCase) { userId = Platform.ToUpperInvariant(userId); } global::System.Collections.IEnumerator enumerator = GetKeyRings().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSecretKeyRing pgpSecretKeyRing = (PgpSecretKeyRing)enumerator.get_Current(); { global::System.Collections.IEnumerator enumerator2 = pgpSecretKeyRing.GetSecretKey().UserIds.GetEnumerator(); try { while (enumerator2.MoveNext()) { string text = (string)enumerator2.get_Current(); string text2 = text; if (ignoreCase) { text2 = Platform.ToUpperInvariant(text2); } if (matchPartial) { if (Platform.IndexOf(text2, userId) > -1) { list.Add((object)pgpSecretKeyRing); } } else if (text2.Equals(userId)) { list.Add((object)pgpSecretKeyRing); } } } finally { global::System.IDisposable disposable2 = enumerator2 as global::System.IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(new EnumerableProxy((global::System.Collections.IEnumerable)list)); }
static PkixCertPath() { global::System.Collections.IList list = Platform.CreateArrayList(); list.Add((object)"PkiPath"); list.Add((object)"PEM"); list.Add((object)"PKCS7"); certPathEncodings = CollectionUtilities.ReadOnly(list); }
private static PemObject CreatePemObject(object obj, string algorithm, char[] password, SecureRandom random) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (obj == null) { throw new ArgumentNullException("obj"); } if (algorithm == null) { throw new ArgumentNullException("algorithm"); } if (password == null) { throw new ArgumentNullException("password"); } if (random == null) { throw new ArgumentNullException("random"); } if (obj is AsymmetricCipherKeyPair) { return(CreatePemObject(((AsymmetricCipherKeyPair)obj).Private, algorithm, password, random)); } string text = null; byte[] array = null; if (obj is AsymmetricKeyParameter) { AsymmetricKeyParameter asymmetricKeyParameter = (AsymmetricKeyParameter)obj; if (asymmetricKeyParameter.IsPrivate) { array = EncodePrivateKey(asymmetricKeyParameter, out var keyType); text = keyType + " PRIVATE KEY"; } } if (text == null || array == null) { throw new PemGenerationException("Object type not supported: " + Platform.GetTypeName(obj)); } string text2 = Platform.ToUpperInvariant(algorithm); if (text2 == "DESEDE") { text2 = "DES-EDE3-CBC"; } int num = (Platform.StartsWith(text2, "AES-") ? 16 : 8); byte[] array2 = new byte[num]; ((Random)random).NextBytes(array2); byte[] content = PemUtilities.Crypt(encrypt: true, array, password, text2, array2); global::System.Collections.IList list = Platform.CreateArrayList(2); list.Add((object)new PemHeader("Proc-Type", "4,ENCRYPTED")); list.Add((object)new PemHeader("DEK-Info", text2 + "," + Hex.ToHexString(array2))); return(new PemObject(text, list, content)); }
public PgpKeyRingGenerator(int certificationLevel, PgpKeyPair masterKey, string id, SymmetricKeyAlgorithmTag encAlgorithm, byte[] rawPassPhrase, bool useSha1, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, SecureRandom rand) { this.certificationLevel = certificationLevel; this.masterKey = masterKey; this.id = id; this.encAlgorithm = encAlgorithm; this.rawPassPhrase = rawPassPhrase; this.useSha1 = useSha1; hashedPacketVector = hashedPackets; unhashedPacketVector = unhashedPackets; this.rand = rand; keys.Add((object)new PgpSecretKey(certificationLevel, masterKey, id, encAlgorithm, rawPassPhrase, clearPassPhrase: false, useSha1, hashedPackets, unhashedPackets, rand)); }
private void DoGetCapabilitiesForOid(DerObjectIdentifier capability, global::System.Collections.IList list) { global::System.Collections.IEnumerator enumerator; if (capability == null) { { enumerator = capabilities.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); SmimeCapability instance = SmimeCapability.GetInstance(current); list.Add((object)instance); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } } return; } enumerator = capabilities.GetEnumerator(); try { while (enumerator.MoveNext()) { object current2 = enumerator.get_Current(); SmimeCapability instance2 = SmimeCapability.GetInstance(current2); if (capability.Equals(instance2.CapabilityID)) { list.Add((object)instance2); } } } finally { global::System.IDisposable disposable2 = enumerator as global::System.IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } }
public virtual object this[object k] { get { return(hash.get_Item(k)); } set { if (!hash.Contains(k)) { keys.Add(k); } hash.set_Item(k, value); } }
public virtual void Encode(Stream output) { global::System.Collections.IList list = Platform.CreateArrayList(mCertificateList.Length); int num = 0; X509CertificateStructure[] array = mCertificateList; foreach (Asn1Encodable asn1Encodable in array) { byte[] encoded = asn1Encodable.GetEncoded("DER"); list.Add((object)encoded); num += encoded.Length + 3; } TlsUtilities.CheckUint24(num); TlsUtilities.WriteUint24(num, output); global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)list).GetEnumerator(); try { while (enumerator.MoveNext()) { byte[] buf = (byte[])enumerator.get_Current(); TlsUtilities.WriteOpaque24(buf, output); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public static CertificateRequest Parse(TlsContext context, Stream input) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown int num = TlsUtilities.ReadUint8(input); byte[] array = new byte[num]; for (int i = 0; i < num; i++) { array[i] = TlsUtilities.ReadUint8(input); } global::System.Collections.IList supportedSignatureAlgorithms = null; if (TlsUtilities.IsTlsV12(context)) { supportedSignatureAlgorithms = TlsUtilities.ParseSupportedSignatureAlgorithms(allowAnonymous: false, input); } global::System.Collections.IList list = Platform.CreateArrayList(); byte[] array2 = TlsUtilities.ReadOpaque16(input); MemoryStream val = new MemoryStream(array2, false); while (((Stream)val).get_Position() < ((Stream)val).get_Length()) { byte[] encoding = TlsUtilities.ReadOpaque16((Stream)(object)val); Asn1Object obj = TlsUtilities.ReadDerObject(encoding); list.Add((object)X509Name.GetInstance(obj)); } return(new CertificateRequest(array, supportedSignatureAlgorithms, list)); }
public global::System.Collections.IEnumerable GetSignaturesOfType(int signatureType) { global::System.Collections.IList list = Platform.CreateArrayList(); global::System.Collections.IEnumerator enumerator = GetSignatures().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSignature pgpSignature = (PgpSignature)enumerator.get_Current(); if (pgpSignature.SignatureType == signatureType) { list.Add((object)pgpSignature); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(new EnumerableProxy((global::System.Collections.IEnumerable)list)); }
public void AddAttributeCertificates(IX509Store store) { try { global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)store.GetMatches(null)).GetEnumerator(); try { while (enumerator.MoveNext()) { IX509AttributeCertificate iX509AttributeCertificate = (IX509AttributeCertificate)enumerator.get_Current(); _certs.Add((object)new DerTaggedObject(explicitly: false, 2, AttributeCertificate.GetInstance(Asn1Object.FromByteArray(iX509AttributeCertificate.GetEncoded())))); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } } catch (global::System.Exception e) { throw new CmsException("error processing attribute certs", e); } }
private void InitParams(IDictionary parameters) { global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)parameters.get_Keys()).GetEnumerator(); global::System.Collections.IList list = Platform.CreateArrayList(); global::System.Collections.IList list2 = Platform.CreateArrayList(); while (enumerator.MoveNext()) { int num = (int)enumerator.get_Current(); byte[] value = (byte[])parameters.get_Item((object)num); if (num == 0) { key = value; } else if (num < 48) { list.Add((object)new Parameter(num, value)); } else { list2.Add((object)new Parameter(num, value)); } } preMessageParameters = new Parameter[((global::System.Collections.ICollection)list).get_Count()]; ((global::System.Collections.ICollection)list).CopyTo((global::System.Array)preMessageParameters, 0); global::System.Array.Sort((global::System.Array)preMessageParameters); postMessageParameters = new Parameter[((global::System.Collections.ICollection)list2).get_Count()]; ((global::System.Collections.ICollection)list2).CopyTo((global::System.Array)postMessageParameters, 0); global::System.Array.Sort((global::System.Array)postMessageParameters); }
public PgpSecretKeyRingBundle(global::System.Collections.IEnumerable e) { secretRings = Platform.CreateHashtable(); order = Platform.CreateArrayList(); global::System.Collections.IEnumerator enumerator = e.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); PgpSecretKeyRing pgpSecretKeyRing = current as PgpSecretKeyRing; if (pgpSecretKeyRing == null) { throw new PgpException(Platform.GetTypeName(current) + " found where PgpSecretKeyRing expected"); } long keyId = pgpSecretKeyRing.GetPublicKey().KeyId; secretRings.Add((object)keyId, (object)pgpSecretKeyRing); order.Add((object)keyId); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
private void AddCertsFromSet(global::System.Collections.IList certs, Asn1Set certSet) { X509CertificateParser x509CertificateParser = new X509CertificateParser(); global::System.Collections.IEnumerator enumerator = certSet.GetEnumerator(); try { while (enumerator.MoveNext()) { Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current(); try { Asn1Object asn1Object = asn1Encodable.ToAsn1Object(); if (asn1Object is Asn1Sequence) { certs.Add((object)x509CertificateParser.ReadCertificate(asn1Object.GetEncoded())); } } catch (global::System.Exception e) { throw new CmsException("can't re-encode certificate!", e); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
private X509Extensions(Asn1Sequence seq) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) ordering = Platform.CreateArrayList(); global::System.Collections.IEnumerator enumerator = seq.GetEnumerator(); try { while (enumerator.MoveNext()) { Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current(); Asn1Sequence instance = Asn1Sequence.GetInstance(asn1Encodable.ToAsn1Object()); if (instance.Count < 2 || instance.Count > 3) { throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)instance.Count)); } DerObjectIdentifier instance2 = DerObjectIdentifier.GetInstance(instance[0].ToAsn1Object()); bool critical = instance.Count == 3 && DerBoolean.GetInstance(instance[1].ToAsn1Object()).IsTrue; Asn1OctetString instance3 = Asn1OctetString.GetInstance(instance[instance.Count - 1].ToAsn1Object()); extensions.Add((object)instance2, (object)new X509Extension(critical, instance3)); ordering.Add((object)instance2); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public virtual void AddCertPathChecker(PkixCertPathChecker checker) { if (checker != null) { certPathCheckers.Add(checker.Clone()); } }
public virtual void SetCertPathCheckers(global::System.Collections.IList checkers) { certPathCheckers = Platform.CreateArrayList(); if (checkers == null) { return; } global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)checkers).GetEnumerator(); try { while (enumerator.MoveNext()) { PkixCertPathChecker pkixCertPathChecker = (PkixCertPathChecker)enumerator.get_Current(); certPathCheckers.Add(pkixCertPathChecker.Clone()); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
private DerObjectIdentifier[] GetExtensionOids(bool isCritical) { global::System.Collections.IList list = Platform.CreateArrayList(); global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)ordering).GetEnumerator(); try { while (enumerator.MoveNext()) { DerObjectIdentifier derObjectIdentifier = (DerObjectIdentifier)enumerator.get_Current(); X509Extension x509Extension = (X509Extension)extensions.get_Item((object)derObjectIdentifier); if (x509Extension.IsCritical == isCritical) { list.Add((object)derObjectIdentifier); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(ToOidArray(list)); }
public static Certificate Parse(Stream input) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown int num = TlsUtilities.ReadUint24(input); if (num == 0) { return(EmptyChain); } byte[] array = TlsUtilities.ReadFully(num, input); MemoryStream val = new MemoryStream(array, false); global::System.Collections.IList list = Platform.CreateArrayList(); while (((Stream)val).get_Position() < ((Stream)val).get_Length()) { byte[] encoding = TlsUtilities.ReadOpaque24((Stream)(object)val); Asn1Object obj = TlsUtilities.ReadDerObject(encoding); list.Add((object)X509CertificateStructure.GetInstance(obj)); } X509CertificateStructure[] array2 = new X509CertificateStructure[((global::System.Collections.ICollection)list).get_Count()]; for (int i = 0; i < ((global::System.Collections.ICollection)list).get_Count(); i++) { array2[i] = (X509CertificateStructure)list.get_Item(i); } return(new Certificate(array2)); }
public static OcspStatusRequest Parse(Stream input) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown global::System.Collections.IList list = Platform.CreateArrayList(); int num = TlsUtilities.ReadUint16(input); if (num > 0) { byte[] array = TlsUtilities.ReadFully(num, input); MemoryStream val = new MemoryStream(array, false); do { byte[] encoding = TlsUtilities.ReadOpaque16((Stream)(object)val); ResponderID instance = ResponderID.GetInstance(TlsUtilities.ReadDerObject(encoding)); list.Add((object)instance); }while (((Stream)val).get_Position() < ((Stream)val).get_Length()); } X509Extensions requestExtensions = null; int num2 = TlsUtilities.ReadUint16(input); if (num2 > 0) { byte[] encoding2 = TlsUtilities.ReadFully(num2, input); requestExtensions = X509Extensions.GetInstance(TlsUtilities.ReadDerObject(encoding2)); } return(new OcspStatusRequest(list, requestExtensions)); }
public SignerInformationStore(global::System.Collections.ICollection signerInfos) { global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)signerInfos).GetEnumerator(); try { while (enumerator.MoveNext()) { SignerInformation signerInformation = (SignerInformation)enumerator.get_Current(); SignerID signerID = signerInformation.SignerID; global::System.Collections.IList list = (global::System.Collections.IList)table.get_Item((object)signerID); if (list == null) { table.set_Item((object)signerID, (object)(list = Platform.CreateArrayList(1))); } list.Add((object)signerInformation); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } all = Platform.CreateArrayList(signerInfos); }
private global::System.Collections.IList GetCertList() { global::System.Collections.IList list = Platform.CreateArrayList(); Asn1Sequence certs = req.OptionalSignature.Certs; if (certs != null) { global::System.Collections.IEnumerator enumerator = certs.GetEnumerator(); try { while (enumerator.MoveNext()) { Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current(); try { list.Add((object)new X509CertificateParser().ReadCertificate(asn1Encodable.GetEncoded())); } catch (global::System.Exception e) { throw new OcspException("can't re-encode certificate!", e); } } return(list); } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } } return(list); }
public virtual void AddStore(IX509Store store) { if (store != null) { stores.Add((object)store); } }
public global::System.Collections.IEnumerable GetUserAttributes() { global::System.Collections.IList list = Platform.CreateArrayList(); global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)ids).GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); if (current is PgpUserAttributeSubpacketVector) { list.Add(current); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(new EnumerableProxy((global::System.Collections.IEnumerable)list)); }
private void AddCrlsFromSet(global::System.Collections.IList crls, Asn1Set crlSet) { X509CrlParser x509CrlParser = new X509CrlParser(); global::System.Collections.IEnumerator enumerator = crlSet.GetEnumerator(); try { while (enumerator.MoveNext()) { Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current(); try { crls.Add((object)x509CrlParser.ReadCrl(asn1Encodable.GetEncoded())); } catch (global::System.Exception e) { throw new CmsException("can't re-encode CRL!", e); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public virtual void AddAdditionalStore(IX509Store store) { if (store != null) { additionalStores.Add((object)store); } }