/// <summary> /// Create a key generation parameter. /// </summary> /// /// <param name="keyType">The type for the created key.</param> /// <param name="keyIdType"></param> /// <exception cref="System.AssertionError">if keyIdType is KeyIdType.USER_SPECIFIED.</exception> protected internal KeyParams(KeyType keyType, KeyIdType keyIdType) { this.keyId_ = new Name.Component(); if (keyIdType == net.named_data.jndn.security.KeyIdType.USER_SPECIFIED) { throw new AssertionError("KeyParams: KeyIdType is USER_SPECIFIED"); } keyType_ = keyType; keyIdType_ = keyIdType; }
/// <summary> /// Returns true if a KeyID matches one in a certificate /// </summary> /// <param name="KeyId">KeyIDvalue to test</param> /// <param name="Certificate">Certificate to test</param> /// <param name="IdType">Authority or Subject KeyID</param> /// <returns> /// True for a key match /// </returns> /// <exception cref="System.ApplicationException">Authority KeyID extension not found in certificate /// or /// Subject KeyID extension not found in certificate</exception> public static bool TestKeyId(byte[] KeyId, X509Certificate Certificate, KeyIdType IdType) { X509Extensions extensions = Certificate.GetExtensions(); X509Extension ext; AuthorityKeyIdentifier akid; SubjectKeyIdentifier skid; switch (IdType) { case KeyIdType.AKID: ext = extensions.GetExtension(X509Extensions.AuthorityKeyIdentifier); if (ext == null) { throw new ApplicationException("Authority KeyID extension not found in certificate"); } else { akid = AuthorityKeyIdentifier.GetInstance(ext); if (KeyId == akid.GetKeyIdentifier()) { return(true); } } break; case KeyIdType.SKID: ext = extensions.GetExtension(X509Extensions.SubjectKeyIdentifier); if (ext == null) { throw new ApplicationException("Subject KeyID extension not found in certificate"); } else { skid = SubjectKeyIdentifier.GetInstance(ext); if (KeyId == skid.GetKeyIdentifier()) { return(true); } } break; } return(false); }
public AesKeyParams(int size, KeyIdType keyIdType) : base(getType(), keyIdType) { size_ = size; }
public EcdsaKeyParams(int size, KeyIdType keyIdType) : base(size, keyIdType) { }