----------------------------------------------------------------------------
-- X509.ASN
--
-- ASN.1 definitions for SCHANNEL DH, FORTEZZA, and Private Key encoding
----------------------------------------------------------------------------

--#comment "Copyright (C) Microsoft Corporation, 1996-1999. All rights reserved."--
--#comment "ASN.1 definitions for SCHANNEL DH, FORTEZZA, and Private Key encoding"--

--#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--

    --------------------------------------------
    --  SCHANNEL Definitions
    --------------------------------------------

    --------------------------------------------
    -- Diffie Hellman Public
    --
	-- DHPublicKey defines the value Y for a 
	-- DH Public Key.
    --------------------------------------------
	DHPublicKey ::=  HUGEINTEGER --#public--   -- Y

    --------------------------------------------
    -- Diffie Hellman Parameters
    --
	-- DHParameters defines the diffie helman
	-- parameters structure, which contains
	-- a prime modulus p, and a generator g.
	-- The optional private value length describes
	-- the length of the private value, if not
	-- the length of the prime modulus.
    --------------------------------------------

    DHParameters ::= SEQUENCE {
        prime         HUGEINTEGER,    -- p
		base          HUGEINTEGER,    -- g
		privateValueLength   INTEGER OPTIONAL
    } --#public--

    --------------------------------------------
    -- DSA Parameters
    --
	-- DHParameters defines the diffie helman
	-- parameters structure, which contains
	-- a prime modulus p, and a generator g.
	-- The optional private value length describes
	-- the length of the private value, if not
	-- the length of the prime modulus.
    --------------------------------------------

    DSAParameters ::= SEQUENCE {
        p          HUGEINTEGER,    -- p
        q          HUGEINTEGER,    -- q
		g          HUGEINTEGER     -- g
    } --#public--

    --------------------------------------------
    -- DSA Public
    --
	-- DSAPublicKey defines the value Y for a 
	-- DSA Public Key.
    --------------------------------------------
	DSAPublicKey ::=  HUGEINTEGER --#public--   -- Y



    --------------------------------------------
    -- Fortezza Public
    --
	-- Fortezza parameters are not ASN.1 encoded,
	-- but are stored in a bitstring.
    --------------------------------------------
	FORTPublicKey ::=  BITSTRING --#public--   -- Fort


	AlgorithmIdentifier	::=	SEQUENCE {
		algorithm				ObjectID,
		parameters				ANY OPTIONAL
	}


	RSAPrivateKey ::= SEQUENCE {
		version         INTEGER,
		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--   

	DSAPrivateKey ::= SEQUENCE {
		version         INTEGER,
		private         HUGEINTEGER               -- x
	} --#public--   

	DHPrivateKey ::= SEQUENCE {
		version         INTEGER,
		private         HUGEINTEGER               -- x
	} --#public--   

	EncryptedData ::= OCTET STRING

	PrivateKeyInfo ::= SEQUENCE {
		version             INTEGER,
		privateKeyAlgorithm AlgorithmIdentifier,
		privateKey          OCTET STRING,
		attributes          [0] IMPLICIT SET OF ANY OPTIONAL 
	} --#public--

	PrivateKeyData ::= SEQUENCE {
		privateKeyAlgorithm	AlgorithmIdentifier,
		privateKey			EncryptedData
	}


	PrivateKeyFile ::= SEQUENCE {
	    name                    OCTET STRING,
		privateKey              PrivateKeyData
	} --#public--


    --------------------------------------------
    --  Enhanced Key Usage Extension (2.5.29.37)
    --------------------------------------------
    EnhancedKeyUsage ::= SEQUENCE --#public-- OF UsageIdentifier

    UsageIdentifier ::= ObjectID



END