/** * Creates a new <code>CommitmentTypeQualifier</code> instance. * * @param commitmentTypeIdentifier a <code>CommitmentTypeIdentifier</code> value * @param qualifier the qualifier, defined by the above field. */ public CommitmentTypeQualifier( DerObjectIdentifier commitmentTypeIdentifier, Asn1Encodable qualifier) { this.commitmentTypeIdentifier = commitmentTypeIdentifier; this.qualifier = qualifier; }
public ArrayList GetCapabilities( DerObjectIdentifier capability) { ArrayList list = new ArrayList(); DoGetCapabilitiesForOid(capability, list); return list; }
private static void DefineCurve( string name, DerObjectIdentifier oid) { objIds.Add(name, oid); names.Add(oid, name); }
public override void PerformTest() { CommitmentTypeQualifier ctq = new CommitmentTypeQualifier(CommitmentTypeIdentifier.ProofOfOrigin); CheckConstruction(ctq, CommitmentTypeIdentifier.ProofOfOrigin, null); Asn1Encodable info = new DerObjectIdentifier("1.2"); ctq = new CommitmentTypeQualifier(CommitmentTypeIdentifier.ProofOfOrigin, info); CheckConstruction(ctq, CommitmentTypeIdentifier.ProofOfOrigin, info); ctq = CommitmentTypeQualifier.GetInstance(null); if (ctq != null) { Fail("null GetInstance() failed."); } try { CommitmentTypeQualifier.GetInstance(new object()); Fail("GetInstance() failed to detect bad object."); } catch (ArgumentException) { // expected } }
public QCStatement( DerObjectIdentifier qcStatementId, Asn1Encodable qcStatementInfo) { this.qcStatementId = qcStatementId; this.qcStatementInfo = qcStatementInfo; }
/** * returns an ArrayList with 0 or more objects of all the capabilities * matching the passed in capability Oid. If the Oid passed is null the * entire set is returned. */ public ArrayList GetCapabilities( DerObjectIdentifier capability) { ArrayList list = new ArrayList(); if (capability == null) { foreach (object o in capabilities) { SmimeCapability cap = SmimeCapability.GetInstance(o); list.Add(cap); } } else { foreach (object o in capabilities) { SmimeCapability cap = SmimeCapability.GetInstance(o); if (capability.Equals(cap.CapabilityID)) { list.Add(cap); } } } return list; }
public DHKdfParameters(DerObjectIdentifier algorithm, int keySize, byte[] z, byte[] extraInfo) { _algorithm = algorithm; _keySize = keySize; _z = z; // TODO Clone? _extraInfo = extraInfo; }
internal DerObjectIdentifier(DerObjectIdentifier oid, string branchID) { if (!IsValidBranchID(branchID, 0)) throw new ArgumentException("string " + branchID + " not a valid OID branch", "branchID"); this.identifier = oid.Id + "." + branchID; }
public ECKeyGenerationParameters( DerObjectIdentifier publicKeyParamSet, SecureRandom random) : this(LookupParameters(publicKeyParamSet), random) { this.publicKeyParamSet = publicKeyParamSet; }
/** * create an AuthorityInformationAccess with the oid and location provided. */ public AuthorityInformationAccess( DerObjectIdentifier oid, GeneralName location) { accessMethod = oid; accessLocation = location; }
private static string Rfc4050XmlMaker(string algo, DerObjectIdentifier keyAlgoOid, X509Certificate2 cert) { if (!algo.Equals("ECDH", StringComparison.InvariantCultureIgnoreCase) && !algo.Equals("ECDSA", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Cannot generate rfc4050 keys for unknown EC algorithm"); algo = algo.ToUpper(); var namedCurve = SecNamedCurves.GetByOid(keyAlgoOid); var publickey = new ECPublicKeyParameters(algo, namedCurve.Curve.DecodePoint(cert.GetPublicKey()), // Q keyAlgoOid); //now we have the public key in bouncy castle //we can create the xml to import to CngKey string xml = "<" + algo + @"KeyValue xmlns='http://www.w3.org/2001/04/xmldsig-more#'> <DomainParameters> <NamedCurve URN='urn:oid:" + keyAlgoOid.Id + @"' /> </DomainParameters> <PublicKey> <X Value='" + publickey.Q.X.ToBigInteger() + @"' xsi:type='PrimeFieldElemType' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' /> <Y Value='" + publickey.Q.Y.ToBigInteger() + @"' xsi:type='PrimeFieldElemType' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' /> </PublicKey> </" + algo + "KeyValue>"; return xml; }
private static void DefineCurveAlias( string name, DerObjectIdentifier oid) { objIds.Add(Platform.ToUpperInvariant(name), oid); names.Add(oid, name); }
public SemanticsInformation( Asn1Sequence seq) { if (seq.Count < 1) { throw new ArgumentException("no objects in SemanticsInformation"); } IEnumerator e = seq.GetEnumerator(); e.MoveNext(); object obj = e.Current; if (obj is DerObjectIdentifier) { semanticsIdentifier = DerObjectIdentifier.GetInstance(obj); if (e.MoveNext()) { obj = e.Current; } else { obj = null; } } if (obj != null) { Asn1Sequence generalNameSeq = Asn1Sequence.GetInstance(obj ); nameRegistrationAuthorities = new GeneralName[generalNameSeq.Count]; for (int i= 0; i < generalNameSeq.Count; i++) { nameRegistrationAuthorities[i] = GeneralName.GetInstance(generalNameSeq[i]); } } }
protected ECPublicBcpgKey( DerObjectIdentifier oid, BigInteger encodedPoint) { this.point = encodedPoint; this.oid = oid; }
/** * add a given extension field for the standard extensions tag (tag 3) * @throws IOException */ public virtual void AddExtension( DerObjectIdentifier oid, bool critical, Asn1Encodable extValue) { this.AddExtension(oid, critical, extValue.GetEncoded()); }
public AttributeX509( DerObjectIdentifier attrType, Asn1Set attrValues) { this.attrType = attrType; this.attrValues = attrValues; }
/// <summary> /// Add an extension to this certificate. /// </summary> /// <param name="oid">Its Object Identifier.</param> /// <param name="critical">Is it critical.</param> /// <param name="extensionValue">The value.</param> public void AddExtension( DerObjectIdentifier oid, bool critical, Asn1Encodable extensionValue) { extGenerator.AddExtension(oid, critical, extensionValue); }
public ContentInfo( DerObjectIdentifier contentType, Asn1Encodable content) { this.contentType = contentType; this.content = content; }
public Gost3410KeyGenerationParameters( ISecureRandom random, DerObjectIdentifier publicKeyParamSet) : this(random, LookupParameters(publicKeyParamSet)) { this.publicKeyParamSet = publicKeyParamSet; }
private void doTestCreateKeyParameter( string algorithm, DerObjectIdentifier oid, int keyBits, Type expectedType, SecureRandom random) { int keyLength = keyBits / 8; byte[] bytes = new byte[keyLength]; random.NextBytes(bytes); KeyParameter key; key = ParameterUtilities.CreateKeyParameter(algorithm, bytes); checkKeyParameter(key, expectedType, bytes); key = ParameterUtilities.CreateKeyParameter(oid, bytes); checkKeyParameter(key, expectedType, bytes); bytes = new byte[keyLength * 2]; random.NextBytes(bytes); int offset = random.Next(1, keyLength); byte[] expected = new byte[keyLength]; Array.Copy(bytes, offset, expected, 0, keyLength); key = ParameterUtilities.CreateKeyParameter(algorithm, bytes, offset, keyLength); checkKeyParameter(key, expectedType, expected); key = ParameterUtilities.CreateKeyParameter(oid, bytes, offset, keyLength); checkKeyParameter(key, expectedType, expected); }
public DHKdfParameters( DerObjectIdentifier algorithm, int keySize, byte[] z) : this(algorithm, keySize, z, null) { }
public SmimeCapability( DerObjectIdentifier capabilityID, Asn1Encodable parameters) { this.capabilityID = capabilityID; this.parameters = parameters; }
public OtherRecipientInfo( DerObjectIdentifier oriType, Asn1Encodable oriValue) { this.oriType = oriType; this.oriValue = oriValue; }
public OtherKeyAttribute( DerObjectIdentifier keyAttrId, Asn1Encodable keyAttr) { this.keyAttrId = keyAttrId; this.keyAttr = keyAttr; }
public CommitmentTypeIndication( DerObjectIdentifier commitmentTypeId, Asn1Sequence commitmentTypeQualifier) { this.commitmentTypeId = commitmentTypeId; this.commitmentTypeQualifier = commitmentTypeQualifier; }
/** * returns an ArrayList with 0 or more objects of all the capabilities * matching the passed in capability Oid. If the Oid passed is null the * entire set is returned. */ public IList GetCapabilitiesForOid( DerObjectIdentifier capability) { IList list = Platform.CreateArrayList(); DoGetCapabilitiesForOid(capability, list); return list; }
/// <summary> /// Initializes a new instance of the <see cref="ECDHPublicKeyParameters" /> class. /// </summary> /// <param name="q">The q.</param> /// <param name="publicKeyParamSet">The public key param set.</param> /// <param name="hashAlgorithm">The hash algorithm.</param> /// <param name="symmetricKeyAlgorithm">The symmetric key algorithm.</param> public ECDHPublicKeyParameters(ECPoint q, DerObjectIdentifier publicKeyParamSet, HashAlgorithmTag hashAlgorithm, SymmetricKeyAlgorithmTag symmetricKeyAlgorithm) : base("ECDH", q, publicKeyParamSet) { this.HashAlgorithm = hashAlgorithm; this.SymmetricKeyAlgorithm = symmetricKeyAlgorithm; }
protected ECPublicBcpgKey( DerObjectIdentifier oid, ECPoint point) { this.point = new BigInteger(1, point.GetEncoded()); this.oid = oid; }
public TimeStampRequest Generate( string digestAlgorithmOid, byte[] digest, BigInteger nonce) { if (digestAlgorithmOid == null) { throw new ArgumentException("No digest algorithm specified"); } DerObjectIdentifier digestAlgOid = new DerObjectIdentifier(digestAlgorithmOid); AlgorithmIdentifier algID = new AlgorithmIdentifier(digestAlgOid, DerNull.Instance); MessageImprint messageImprint = new MessageImprint(algID, digest); X509Extensions ext = null; if (extOrdering.Count != 0) { ext = new X509Extensions(extOrdering, extensions); } DerInteger derNonce = nonce == null ? null : new DerInteger(nonce); return new TimeStampRequest( new TimeStampReq(messageImprint, reqPolicy, derNonce, certReq, ext)); }
public SemanticsInformation( DerObjectIdentifier semanticsIdentifier, GeneralName[] generalNames) { this.semanticsIdentifier = semanticsIdentifier; this.nameRegistrationAuthorities = generalNames; }
public static string GetCertificateValue(X509Certificate certificate, string identifier) { DerObjectIdentifier commonNameOID = new Org.BouncyCastle.Asn1.DerObjectIdentifier(identifier); IList values = certificate.SubjectDN.GetValueList(commonNameOID); if (values.Count > 0) { return((string)values[0]); } return(null); }
public override Org.BouncyCastle.Asn1.Asn1Object GetConvertedValue(Org.BouncyCastle.Asn1.DerObjectIdentifier oid, string value) { Asn1Object obj = base.GetConvertedValue(oid, value); if (obj is DerUtf8String) { return(new DerPrintableString(value)); } else { return(obj); } }
/** * Return true if this oid is an extension of the passed in branch, stem. * @param stem the arc or branch that is a possible parent. * @return true if the branch is on the passed in stem, false otherwise. */ public virtual bool On(DerObjectIdentifier stem) { string id = Id, stemId = stem.Id; return(id.Length > stemId.Length && id[stemId.Length] == '.' && Platform.StartsWith(id, stemId)); }