----------------------------------------------------------------------------
-- X509.ASN
--
-- ASN.1 definitions for X509 v3 certificates
----------------------------------------------------------------------------

--#comment "Copyright (C) Microsoft Corporation, 1996-1999. All rights reserved."--
--#comment "ASN.1 definitions for X509 v3 certificates"--

--#oid array--         -- object identifier is 16-node fixed array
--#SS.basic lenptr--   -- set of and sequence of w/o size constraint
--#SS.sized lenptr--   -- set of and sequence of w/  size constraint

X509
DEFINITIONS EXPLICIT TAGS ::=
BEGIN

    HUGEINTEGER ::= INTEGER --#intx--                       -- tag 0x02
    BITSTRING   ::= BIT STRING --#lenptr-- --#nomemcpy--   -- tag 0x03
    OCTETSTRING ::= OCTET STRING --#lenptr-- --#nomemcpy-- -- tag 0x04
    NOCOPYANY   ::= ANY --#nomemcpy--

    NUMERICSTRING ::= NumericString --#lenptr--         -- tag 0x12 (18)
    PRINTABLESTRING ::= PrintableString --#lenptr--     -- tag 0x13 (19)
    TELETEXSTRING ::= TeletexString --#lenptr--         -- tag 0x14 (20)
    T61STRING ::= T61String --#lenptr--                 -- tag 0x14 (20)
    VIDEOTEXSTRING ::= VideotexString --#lenptr--       -- tag 0x15 (21)
    IA5STRING ::= IA5String --#lenptr--                 -- tag 0x16 (22)
    GRAPHICSTRING ::= GraphicString --#lenptr--         -- tag 0x19 (25)
    VISIBLESTRING ::= VisibleString --#lenptr--         -- tag 0x1A (26)
    ISO646STRING ::= ISO646String --#lenptr--           -- tag 0x1A (26)
    GENERALSTRING ::= GeneralString --#lenptr--         -- tag 0x1B (27)
    UNIVERSALSTRING ::= UniversalString --#lenptr--     -- tag 0x1C (28)
    BMPSTRING ::= BMPString --#lenptr--                 -- tag 0x1E (30)

    ObjectID ::= OBJECT IDENTIFIER --#oid array--
   
    --------------------------------------------
    --  Algorithm Identifier
    --------------------------------------------
    AlgorithmIdentifier    ::=    SEQUENCE {
	algorithm           ObjectID,
	parameters          NOCOPYANY OPTIONAL    
    }

    --------------------------------------------
    --  Attributes
    --------------------------------------------
    Attribute ::= SEQUENCE {
	type       ObjectID,
	values     AttributeSetValue
    } --#public--

    AttributeSetValue ::= SET OF NOCOPYANY
    Attributes ::= SET OF Attribute

   
	--------------------------------------------
    --  Private Key types
    --------------------------------------------
	Version ::= INTEGER

	RSAPrivateKey   ::= SEQUENCE {
		version                 Version,
		modulus                 HUGEINTEGER,    -- n
		publicExponent  INTEGER,                -- e
		privateExponent HUGEINTEGER,    -- d
		prime1                  HUGEINTEGER,    -- p
		prime2                  HUGEINTEGER,    -- q
		exponent1               HUGEINTEGER,    -- d mod (p-1)
		exponent2               HUGEINTEGER,    -- d mod (q-1)
		coefficient             HUGEINTEGER             -- (inverse of q) mod p
	} --#public--

    PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier

	PrivateKey ::= OCTETSTRING

	PrivateKeyInfo ::= SEQUENCE {
		version                         Version,
		privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
		privateKey                      PrivateKey,
		privateKeyAttributes    [0] IMPLICIT Attributes OPTIONAL
	} --#public--

	EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier

	EncryptedData ::= OCTETSTRING

	EncryptedPrivateKeyInfo ::= SEQUENCE {
		encryptionAlgorithm EncryptionAlgorithmIdentifier,
		encryptedData           EncryptedData
	} --#public--

END