Merge pull request #1057 from lextm/master
[mono.git] / mcs / class / Mono.Security / Mono.Security.X509.Extensions / AuthorityKeyIdentifierExtension.cs
index 193014698225489d57e5ef6b551652569b654e8d..858ee1e7e59895c7cbe55cee79deb47da343127c 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Sebastien Pouliot  <sebastien@ximian.com>
 //
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005,2007 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -46,7 +46,12 @@ namespace Mono.Security.X509.Extensions {
         * KeyIdentifier ::= OCTET STRING
         */
 
-       public class AuthorityKeyIdentifierExtension : X509Extension {
+#if INSIDE_SYSTEM
+       internal
+#else
+       public
+#endif
+       class AuthorityKeyIdentifierExtension : X509Extension {
 
                private byte[] aki;
 
@@ -74,14 +79,26 @@ namespace Mono.Security.X509.Extensions {
                                        case 0x80:
                                                aki = el.Value;
                                                break;
-                                       case 0x81:
-                                       case 0x82:
                                        default:
-                                               throw new ArgumentException ("Invalid AuthorityKeyIdentifier extension");
+                                               // don't throw on stuff we don't yet support
+                                               // e.g. authorityCertIssuer/authorityCertSerialNumber
+                                               break;
                                }
                        }
                }
 
+               protected override void Encode ()
+               {
+                       ASN1 seq = new ASN1 (0x30);
+                       if (aki == null) {
+                               throw new InvalidOperationException ("Invalid AuthorityKeyIdentifier extension");
+                       }
+
+                       seq.Add (new ASN1 (0x80, aki));
+                       extnValue = new ASN1 (0x04);
+                       extnValue.Add (seq);
+               }
+
                public override string Name {
                        get { return "Authority Key Identifier"; }
                }
@@ -92,6 +109,7 @@ namespace Mono.Security.X509.Extensions {
                                        return null;
                                return (byte[]) aki.Clone (); 
                        }
+                       set { aki = value; }
                }
 
                public override string ToString ()