2 // AuthorityKeyIdentifierExtension.cs: Handles X.509 AuthorityKeyIdentifier extensions.
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // (C) 2004 Novell (http://www.novell.com)
11 using System.Globalization;
15 using Mono.Security.X509;
17 namespace Mono.Security.X509.Extensions {
20 * id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 }
22 * AuthorityKeyIdentifier ::= SEQUENCE {
23 * keyIdentifier [0] KeyIdentifier OPTIONAL,
24 * authorityCertIssuer [1] GeneralNames OPTIONAL,
25 * authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL }
27 * KeyIdentifier ::= OCTET STRING
30 public class AuthorityKeyIdentifierExtension : X509Extension {
34 public AuthorityKeyIdentifierExtension () : base ()
36 extnOid = "2.5.29.35";
39 public AuthorityKeyIdentifierExtension (ASN1 asn1) : base (asn1)
43 public AuthorityKeyIdentifierExtension (X509Extension extension) : base (extension)
47 protected override void Decode ()
49 ASN1 sequence = new ASN1 (extnValue.Value);
50 if (sequence.Tag != 0x30)
51 throw new ArgumentException ("Invalid AuthorityKeyIdentifier extension");
52 for (int i=0; i < sequence.Count; i++) {
53 ASN1 el = sequence [i];
61 throw new ArgumentException ("Invalid AuthorityKeyIdentifier extension");
66 public override string Name {
67 get { return "Authority Key Identifier"; }
70 public override string ToString ()
72 StringBuilder sb = new StringBuilder ();
77 while (x < aki.Length) {
78 sb.Append (aki [x].ToString ("X2", CultureInfo.InvariantCulture));
85 // [2] CertificateSerialNumber
88 return sb.ToString ();