public override bool Equals( object obj) { if (obj == this) { return(true); } PgpUserAttributeSubpacketVector other = obj as PgpUserAttributeSubpacketVector; if (other == null) { return(false); } if (other.packets.Length != packets.Length) { return(false); } for (int i = 0; i != packets.Length; i++) { if (!other.packets[i].Equals(packets[i])) { return(false); } } return(true); }
/// <summary> /// Verify the signature as certifying the passed in public key as associated /// with the passed in user attributes. /// </summary> /// <param name="userAttributes">User attributes the key was stored under.</param> /// <param name="key">The key to be verified.</param> /// <returns>True, if the signature matches, false otherwise.</returns> public bool VerifyCertification( PgpUserAttributeSubpacketVector userAttributes, PgpPublicKey key) { UpdateWithPublicKey(key); // // hash in the userAttributes // try { MemoryStream bOut = new MemoryStream(); foreach (UserAttributeSubpacket packet in userAttributes.ToSubpacketArray()) { packet.Encode(bOut); } UpdateWithIdData(0xd1, bOut.ToArray()); } catch (IOException e) { throw new PgpException("cannot encode subpacket array", e); } this.Update(sigPck.GetSignatureTrailer()); return(sig.VerifySignature(this.GetSignature())); }
/// <summary>Generate a certification for the passed in userAttributes.</summary> /// <param name="userAttributes">The ID we are certifying against the public key.</param> /// <param name="pubKey">The key we are certifying against the ID.</param> /// <returns>The certification.</returns> public PgpSignature GenerateCertification( PgpUserAttributeSubpacketVector userAttributes, PgpPublicKey pubKey) { UpdateWithPublicKey(pubKey); // // hash in the attributes // try { MemoryStream bOut = new MemoryStream(); foreach (UserAttributeSubpacket packet in userAttributes.ToSubpacketArray()) { packet.Encode(bOut); } UpdateWithIdData(0xd1, bOut.ToArray()); } catch (IOException e) { throw new PgpException("cannot encode subpacket array", e); } return(this.Generate()); }
/// <summary>Remove a certification associated with a given user attributes on a key.</summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="userAttributes">The user attributes that the certfication is to be removed from.</param> /// <param name="certification">The certification to be removed.</param> /// <returns>The re-certified key, or null if the certification was not found.</returns> public static PgpPublicKey RemoveCertification( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes, PgpSignature certification) { return(RemoveCert(key, userAttributes, certification)); }
public void Encode( Stream outStr) { BcpgOutputStream bcpgOut = BcpgOutputStream.Wrap(outStr); bcpgOut.WritePacket(secret); if (pub.trustPk != null) { bcpgOut.WritePacket(pub.trustPk); } if (pub.subSigs == null) // is not a sub key { foreach (PgpSignature keySig in pub.keySigs) { keySig.Encode(bcpgOut); } for (int i = 0; i != pub.ids.Count; i++) { object pubID = pub.ids[i]; if (pubID is string) { string id = (string)pubID; bcpgOut.WritePacket(new UserIdPacket(id)); } else { PgpUserAttributeSubpacketVector v = (PgpUserAttributeSubpacketVector)pubID; bcpgOut.WritePacket(new UserAttributePacket(v.ToSubpacketArray())); } if (pub.idTrusts[i] != null) { bcpgOut.WritePacket((ContainedPacket)pub.idTrusts[i]); } foreach (PgpSignature sig in (IList)pub.idSigs[i]) { sig.Encode(bcpgOut); } } } else { foreach (PgpSignature subSig in pub.subSigs) { subSig.Encode(bcpgOut); } } // TODO Check that this is right/necessary //bcpgOut.Finish(); }
public global::System.Collections.IEnumerable GetSignaturesForUserAttribute(PgpUserAttributeSubpacketVector userAttributes) { for (int i = 0; i != ((global::System.Collections.ICollection)ids).get_Count(); i++) { if (userAttributes.Equals(ids.get_Item(i))) { return(new EnumerableProxy((global::System.Collections.IEnumerable)(global::System.Collections.IList) idSigs.get_Item(i))); } } return(null); }
/// <summary>Allows enumeration of signatures associated with the passed in user attributes.</summary> /// <param name="userAttributes">The vector of user attributes to be matched.</param> /// <returns>An <c>IEnumerable</c> of <c>PgpSignature</c> objects.</returns> public IEnumerable GetSignaturesForUserAttribute( PgpUserAttributeSubpacketVector userAttributes) { for (int i = 0; i != ids.Count; i++) { if (userAttributes.Equals(ids[i])) { return(new EnumerableProxy((IList)idSigs[i])); } } return(null); }
public void Encode( Stream outStr) { BcpgOutputStream bcpgOut = BcpgOutputStream.Wrap(outStr); bcpgOut.WritePacket(publicPk); if (trustPk != null) { bcpgOut.WritePacket(trustPk); } if (subSigs == null) // not a sub-key { foreach (PgpSignature keySig in keySigs) { keySig.Encode(bcpgOut); } for (int i = 0; i != ids.Count; i++) { if (ids[i] is string) { string id = (string)ids[i]; bcpgOut.WritePacket(new UserIdPacket(id)); } else { PgpUserAttributeSubpacketVector v = (PgpUserAttributeSubpacketVector)ids[i]; bcpgOut.WritePacket(new UserAttributePacket(v.ToSubpacketArray())); } if (idTrusts[i] != null) { bcpgOut.WritePacket((ContainedPacket)idTrusts[i]); } foreach (PgpSignature sig in (IList)idSigs[i]) { sig.Encode(bcpgOut); } } } else { foreach (PgpSignature subSig in subSigs) { subSig.Encode(bcpgOut); } } }
public PgpSignature GenerateCertification(PgpUserAttributeSubpacketVector userAttributes, PgpPublicKey pubKey) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0046: Expected O, but got Unknown UpdateWithPublicKey(pubKey); try { MemoryStream val = new MemoryStream(); UserAttributeSubpacket[] array = userAttributes.ToSubpacketArray(); foreach (UserAttributeSubpacket userAttributeSubpacket in array) { userAttributeSubpacket.Encode((Stream)(object)val); } UpdateWithIdData(209, val.ToArray()); } catch (IOException val2) { IOException exception = val2; throw new PgpException("cannot encode subpacket array", (global::System.Exception)(object) exception); } return(Generate()); }
/// <summary>Generate a certification for the passed in userAttributes.</summary> /// <param name="userAttributes">The ID we are certifying against the public key.</param> /// <param name="pubKey">The key we are certifying against the ID.</param> /// <returns>The certification.</returns> public PgpSignature GenerateCertification( PgpUserAttributeSubpacketVector userAttributes, PgpPublicKey pubKey) { UpdateWithPublicKey(pubKey); // // hash in the attributes // try { MemoryStream bOut = new MemoryStream(); foreach (UserAttributeSubpacket packet in userAttributes.ToSubpacketArray()) { packet.Encode(bOut); } UpdateWithIdData(0xd1, bOut.ToArray()); } catch (IOException e) { throw new PgpException("cannot encode subpacket array", e); } return this.Generate(); }
public static PgpPublicKey RemoveCertification(PgpPublicKey key, PgpSignature certification) { PgpPublicKey pgpPublicKey = new PgpPublicKey(key); global::System.Collections.IList list = ((pgpPublicKey.subSigs != null) ? pgpPublicKey.subSigs : pgpPublicKey.keySigs); int num = list.IndexOf((object)certification); bool flag = num >= 0; if (flag) { list.RemoveAt(num); } else { { global::System.Collections.IEnumerator enumerator = key.GetUserIds().GetEnumerator(); try { while (enumerator.MoveNext()) { string id = (string)enumerator.get_Current(); { global::System.Collections.IEnumerator enumerator2 = key.GetSignaturesForId(id).GetEnumerator(); try { while (enumerator2.MoveNext()) { object current = enumerator2.get_Current(); if (certification == current) { flag = true; pgpPublicKey = RemoveCertification(pgpPublicKey, id, certification); } } } 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(); } } } if (!flag) { global::System.Collections.IEnumerator enumerator = key.GetUserAttributes().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpUserAttributeSubpacketVector userAttributes = (PgpUserAttributeSubpacketVector)enumerator.get_Current(); { global::System.Collections.IEnumerator enumerator2 = key.GetSignaturesForUserAttribute(userAttributes).GetEnumerator(); try { while (enumerator2.MoveNext()) { object current2 = enumerator2.get_Current(); if (certification == current2) { flag = true; pgpPublicKey = RemoveCertification(pgpPublicKey, userAttributes, certification); } } } finally { global::System.IDisposable disposable4 = enumerator2 as global::System.IDisposable; if (disposable4 != null) { disposable4.Dispose(); } } } } return(pgpPublicKey); } finally { global::System.IDisposable disposable3 = enumerator as global::System.IDisposable; if (disposable3 != null) { disposable3.Dispose(); } } } } return(pgpPublicKey); }
public void Encode(Stream outStr) { BcpgOutputStream bcpgOutputStream = BcpgOutputStream.Wrap(outStr); bcpgOutputStream.WritePacket(publicPk); if (trustPk != null) { bcpgOutputStream.WritePacket(trustPk); } global::System.Collections.IEnumerator enumerator; if (subSigs == null) { { enumerator = ((global::System.Collections.IEnumerable)keySigs).GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSignature pgpSignature = (PgpSignature)enumerator.get_Current(); pgpSignature.Encode((Stream)(object)bcpgOutputStream); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } } for (int i = 0; i != ((global::System.Collections.ICollection)ids).get_Count(); i++) { if (ids.get_Item(i) is string) { string id = (string)ids.get_Item(i); bcpgOutputStream.WritePacket(new UserIdPacket(id)); } else { PgpUserAttributeSubpacketVector pgpUserAttributeSubpacketVector = (PgpUserAttributeSubpacketVector)ids.get_Item(i); bcpgOutputStream.WritePacket(new UserAttributePacket(pgpUserAttributeSubpacketVector.ToSubpacketArray())); } if (idTrusts.get_Item(i) != null) { bcpgOutputStream.WritePacket((ContainedPacket)idTrusts.get_Item(i)); } { enumerator = ((global::System.Collections.IEnumerable)(global::System.Collections.IList) idSigs.get_Item(i)).GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSignature pgpSignature2 = (PgpSignature)enumerator.get_Current(); pgpSignature2.Encode((Stream)(object)bcpgOutputStream); } } finally { global::System.IDisposable disposable2 = enumerator as global::System.IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } } return; } enumerator = ((global::System.Collections.IEnumerable)subSigs).GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSignature pgpSignature3 = (PgpSignature)enumerator.get_Current(); pgpSignature3.Encode((Stream)(object)bcpgOutputStream); } } finally { global::System.IDisposable disposable3 = enumerator as global::System.IDisposable; if (disposable3 != null) { disposable3.Dispose(); } } }
/// <summary> /// Verify the signature as certifying the passed in public key as associated /// with the passed in user attributes. /// </summary> /// <param name="userAttributes">User attributes the key was stored under.</param> /// <param name="key">The key to be verified.</param> /// <returns>True, if the signature matches, false otherwise.</returns> public bool VerifyCertification( PgpUserAttributeSubpacketVector userAttributes, PgpPublicKey key) { UpdateWithPublicKey(key); // // hash in the userAttributes // try { MemoryStream bOut = new MemoryStream(); foreach (UserAttributeSubpacket packet in userAttributes.ToSubpacketArray()) { packet.Encode(bOut); } UpdateWithIdData(0xd1, bOut.ToArray()); } catch (IOException e) { throw new PgpException("cannot encode subpacket array", e); } this.Update(sigPck.GetSignatureTrailer()); return sig.VerifySignature(this.GetSignature()); }
/// <summary> /// Remove any certifications associated with a user attribute subpacket on a key. /// </summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="userAttributes">The attributes to be removed.</param> /// <returns> /// The re-certified key, or null if the user attribute subpacket was not found on the key. /// </returns> public static IPgpPublicKey RemoveCertification(IPgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes) { return(RemoveCert(key, userAttributes)); }
/// <summary> /// Remove any certifications associated with a user attribute subpacket on a key. /// </summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="userAttributes">The attributes to be removed.</param> /// <returns> /// The re-certified key, or null if the user attribute subpacket was not found on the key. /// </returns> public static IPgpPublicKey RemoveCertification(IPgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes) { return RemoveCert(key, userAttributes); }
/// <summary>Remove a certification associated with a given user attributes on a key.</summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="userAttributes">The user attributes that the certfication is to be removed from.</param> /// <param name="certification">The certification to be removed.</param> /// <returns>The re-certified key, or null if the certification was not found.</returns> public static PgpPublicKey RemoveCertification( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes, PgpSignature certification) { return RemoveCert(key, userAttributes, certification); }
/// <summary>Allows enumeration of signatures associated with the passed in user attributes.</summary> /// <param name="userAttributes">The vector of user attributes to be matched.</param> /// <returns>An <c>IEnumerable</c> of <c>PgpSignature</c> objects.</returns> public IEnumerable GetSignaturesForUserAttribute( PgpUserAttributeSubpacketVector userAttributes) { for (int i = 0; i != ids.Count; i++) { if (userAttributes.Equals(ids[i])) { return new EnumerableProxy((IList) idSigs[i]); } } return null; }