Import of old SSLeay release: SSLeay 0.9.0b
[openssl.git] / doc / a_verify.doc
1 From eay@mincom.com Fri Oct  4 18:29:06 1996
2 Received: by orb.mincom.oz.au id AA29080
3   (5.65c/IDA-1.4.4 for eay); Fri, 4 Oct 1996 08:29:07 +1000
4 Date: Fri, 4 Oct 1996 08:29:06 +1000 (EST)
5 From: Eric Young <eay@mincom.oz.au>
6 X-Sender: eay@orb
7 To: wplatzer <wplatzer@iaik.tu-graz.ac.at>
8 Cc: Eric Young <eay@mincom.oz.au>, SSL Mailing List <ssl-users@mincom.com>
9 Subject: Re: Netscape's Public Key
10 In-Reply-To: <19961003134837.NTM0049@iaik.tu-graz.ac.at>
11 Message-Id: <Pine.SOL.3.91.961004081346.8018K-100000@orb>
12 Mime-Version: 1.0
13 Content-Type: TEXT/PLAIN; charset=US-ASCII
14 Status: RO
15 X-Status: 
16
17 On Thu, 3 Oct 1996, wplatzer wrote:
18 > I get Public Key from Netscape (Gold 3.0b4), but cannot do anything
19 > with it... It looks like (asn1parse):
20
21 > 0:d=0 hl=3 l=180 cons: SEQUENCE
22 > 3:d=1 hl=2 l= 96 cons: SEQUENCE
23 > 5:d=2 hl=2 l= 92 cons: SEQUENCE
24 > 7:d=3 hl=2 l= 13 cons: SEQUENCE
25 > 9:d=4 hl=2 l= 9 prim: OBJECT :rsaEncryption
26 > 20:d=4 hl=2 l= 0 prim: NULL
27 > 22:d=3 hl=2 l= 75 prim: BIT STRING
28 > 99:d=2 hl=2 l= 0 prim: IA5STRING :
29 > 101:d=1 hl=2 l= 13 cons: SEQUENCE
30 > 103:d=2 hl=2 l= 9 prim: OBJECT :md5withRSAEncryption
31 > 114:d=2 hl=2 l= 0 prim: NULL
32 > 116:d=1 hl=2 l= 65 prim: BIT STRING
33
34 > The first BIT STRING is the public key and the second BIT STRING is 
35 > the signature.
36 > But a public key consists of the public exponent and the modulus. Are 
37 > both numbers in the first BIT STRING?
38 > Is there a document simply describing this coding stuff (checking 
39 > signature, get the public key, etc.)?
40
41 Minimal in SSLeay.  If you want to see what the modulus and exponent are,
42 try asn1parse -offset 25 -length 75 <key.pem
43 asn1parse will currently stuff up on the 'length 75' part (fixed in next 
44 release) but it will print the stuff.  If you are after more 
45 documentation on ASN.1, have a look at www.rsa.com and get their PKCS 
46 documents, most of my initial work on SSLeay was done using them.
47
48 As for SSLeay,
49 util/crypto.num and util/ssl.num are lists of all exported functions in 
50 the library (but not macros :-(.
51
52 The ones for extracting public keys from certificates and certificate 
53 requests are EVP_PKEY *      X509_REQ_extract_key(X509_REQ *req);
54 EVP_PKEY *      X509_extract_key(X509 *x509);
55
56 To verify a signature on a signed ASN.1 object
57 int X509_verify(X509 *a,EVP_PKEY *key);
58 int X509_REQ_verify(X509_REQ *a,EVP_PKEY *key);
59 int X509_CRL_verify(X509_CRL *a,EVP_PKEY *key);
60 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a,EVP_PKEY *key);
61
62 I should mention that EVP_PKEY can be used to hold a public or a private key,
63 since for  things like RSA and DSS, a public key is just a subset of what 
64 is stored for the private key.
65
66 To sign any of the above structures
67
68 int X509_sign(X509 *a,EVP_PKEY *key,EVP_MD *md);
69 int X509_REQ_sign(X509_REQ *a,EVP_PKEY *key,EVP_MD *md);
70 int X509_CRL_sign(X509_CRL *a,EVP_PKEY *key,EVP_MD *md);
71 int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *a,EVP_PKEY *key,EVP_MD *md);
72
73 where md is the message digest to sign with.
74
75 There are all defined in x509.h and all the _sign and _verify functions are
76 actually macros to the ASN1_sign() and ASN1_verify() functions.
77 These functions will put the correct algorithm identifiers in the correct 
78 places in the structures.
79
80 eric
81 --
82 Eric Young                  | BOOL is tri-state according to Bill Gates.
83 AARNet: eay@mincom.oz.au    | RTFM Win32 GetMessage().
84
85