public override void PerformTest() { TypeOfBiometricData dataType = new TypeOfBiometricData(TypeOfBiometricData.HandwrittenSignature); AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1, DerNull.Instance); Asn1OctetString dataHash = new DerOctetString(GenerateHash()); BiometricData bd = new BiometricData(dataType, hashAlgorithm, dataHash); CheckConstruction(bd, dataType, hashAlgorithm, dataHash, null); DerIA5String dataUri = new DerIA5String("http://test"); bd = new BiometricData(dataType, hashAlgorithm, dataHash, dataUri); CheckConstruction(bd, dataType, hashAlgorithm, dataHash, dataUri); bd = BiometricData.GetInstance(null); if (bd != null) { Fail("null GetInstance() failed."); } try { BiometricData.GetInstance(new object()); Fail("GetInstance() failed to detect bad object."); } catch (ArgumentException) { // expected } }
public BiometricData( TypeOfBiometricData typeOfBiometricData, AlgorithmIdentifier hashAlgorithm, Asn1OctetString biometricDataHash) { this.typeOfBiometricData = typeOfBiometricData; this.hashAlgorithm = hashAlgorithm; this.biometricDataHash = biometricDataHash; this.sourceDataUri = null; }
private BiometricData( Asn1Sequence seq) { typeOfBiometricData = TypeOfBiometricData.GetInstance(seq[0]); hashAlgorithm = AlgorithmIdentifier.GetInstance(seq[1]); biometricDataHash = Asn1OctetString.GetInstance(seq[2]); if (seq.Count > 3) { sourceDataUri = DerIA5String.GetInstance(seq[3]); } }
private void CheckConstruction( BiometricData bd, TypeOfBiometricData dataType, AlgorithmIdentifier hashAlgorithm, Asn1OctetString dataHash, DerIA5String dataUri) { CheckValues(bd, dataType, hashAlgorithm, dataHash, dataUri); bd = BiometricData.GetInstance(bd); CheckValues(bd, dataType, hashAlgorithm, dataHash, dataUri); Asn1Sequence seq = (Asn1Sequence) Asn1Object.FromByteArray(bd.ToAsn1Object().GetEncoded()); bd = BiometricData.GetInstance(seq); CheckValues(bd, dataType, hashAlgorithm, dataHash, dataUri); }
public VerisignCzagExtension(DerIA5String str) : base(str.GetString()) { }
public NetscapeRevocationUrl(DerIA5String str) : base(str.GetString()) { }
private static PolicyInformation[] GetPolicyInformation(AdESPolicy policy) { if (policy == null) { throw new ArgumentException("La politica de firma no puede ser nula en este punto"); } /** * PolicyQualifierInfo ::= SEQUENCE { * policyQualifierId PolicyQualifierId, * qualifier ANY DEFINED BY policyQualifierId } */ PolicyQualifierID pqid = PolicyQualifierID.IdQtCps; DerIA5String uri = null; if (policy.GetPolicyQualifier() != null && !policy.GetPolicyQualifier().Equals("")) { uri = new DerIA5String(policy.GetPolicyQualifier().ToString()); } Asn1EncodableVector v = new Asn1EncodableVector(); PolicyQualifierInfo pqi = null; if (uri != null) { v.Add(pqid); v.Add(uri); /** * * ESTO TIENE ALTAS PROBABILIDADES DE FALLAR * */ pqi = PolicyQualifierInfo.GetInstance(new DerSequence(v)); } /** * PolicyInformation ::= SEQUENCE { * policyIdentifier CertPolicyId, * policyQualifiers SEQUENCE SIZE (1..MAX) OF * PolicyQualifierInfo OPTIONAL } */ if (policy.GetPolicyQualifier() == null || pqi == null) { return new PolicyInformation[] { new PolicyInformation(new DerObjectIdentifier(policy.GetPolicyIdentifier().ToLower().Replace("urn:oid:", ""))) }; } return new PolicyInformation[] { new PolicyInformation(new DerObjectIdentifier(policy.GetPolicyIdentifier().ToLower().Replace("urn:oid:", "")), new DerSequence(pqi)) }; }
protected override bool Asn1Equals(Asn1Object asn1Object) { DerIA5String derIA5String = asn1Object as DerIA5String; return(derIA5String != null && this.str.Equals(derIA5String.str)); }
private void CheckValues( BiometricData bd, TypeOfBiometricData dataType, AlgorithmIdentifier algID, Asn1OctetString dataHash, DerIA5String sourceDataURI) { if (!bd.TypeOfBiometricData.Equals(dataType)) { Fail("types don't match."); } if (!bd.HashAlgorithm.Equals(algID)) { Fail("hash algorithms don't match."); } if (!bd.BiometricDataHash.Equals(dataHash)) { Fail("hash algorithms don't match."); } if (sourceDataURI != null) { if (!bd.SourceDataUri.Equals(sourceDataURI)) { Fail("data uris don't match."); } } else if (bd.SourceDataUri != null) { Fail("data uri found when none expected."); } }