Hello,
> My question is: how many bytes does public key(EC or RSA) takes in X509
> certificate ? 64B for EC and 162B for RSA. Does X509 contain whole RSA
> public key structure(162) in itself or only 1024bit modulus and 4 bytes for
> exponent ? Does 
Public key for RSA in X509 contains ASN.1 SEQUENCE of INTEGER modulus
and INTEGER public_exponent. Look at RFC2459 7.3.1
For EC you may simply check:

$ openssl ec -in ec-key.pem -text -noout
Private-Key: (224 bit)
priv:
    47:ed:fe:43:2b:1a:7f:27:ed:e3:99:0a:5b:af:e7:
    33:03:cc:5a:2f:da:b9:a3:06:e8:3f:d6:7d
pub:
    04:ca:77:df:dc:af:86:a7:e0:a0:4f:c2:29:5d:fc:
    be:0b:75:60:ca:7c:a2:f8:bf:0d:4e:53:f2:cf:1e:
    5a:98:02:a7:72:e0:3e:34:9c:04:fe:fa:1c:f4:1a:
    c9:26:1b:0a:8f:5d:a2:fb:73:32:0c:a4
ASN1 OID: secp224r1

$ openssl req -new -key ec-key.pem -out req.pem

$  openssl asn1parse -in req.pem -dump
....  
   80:d=2  hl=2 l=  78 cons: SEQUENCE
   82:d=3  hl=2 l=  16 cons: SEQUENCE
   84:d=4  hl=2 l=   7 prim: OBJECT            :id-ecPublicKey
   93:d=4  hl=2 l=   5 prim: OBJECT            :secp224r1
  100:d=3  hl=2 l=  58 prim: BIT STRING
      0000 - 00 04 ca 77 df dc af 86-a7 e0 a0 4f c2 29 5d
fc   ...w.......O.)].
      0010 - be 0b 75 60 ca 7c a2 f8-bf 0d 4e 53 f2 cf 1e
5a   ..u`.|....NS...Z
      0020 - 98 02 a7 72 e0 3e 34 9c-04 fe fa 1c f4 1a c9
26   ...r.>4........&
      0030 - 1b 0a 8f 5d a2 fb 73 32-0c
a4                     ...]..s2..
  160:d=2  hl=2 l=   0 cons: cont [ 0 ]
....

Best regards,
-- 
Marek Marcola <[EMAIL PROTECTED]>

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to