Cryptography Reference
In-Depth Information
X
Y
compressed/uncompressed
Figure 9-6: X9.62 ECC point encoding
The end of Listing 9-35 illustrates this parsing. Because every byte-aligned
ASN.1 bit string must begin with a leading 0 byte as discussed in Chapter 5,
the parsing must skip over this 0 byte and the “compressed/uncompressed”
declaration. The remainder is split down the middle and the fi rst half becomes
the x point and the second half the y point.
Recall that the function parse_x509_chain , introduced in Listing 6-29, is
responsible for parsing a certifi cate and copying its public key info into that of
the TLSParameters structure. This must be modifi ed as shown in Listing 9-36
to recognize the case of ECDSA.
Listing 9-36: “x509.c” parse_x509_chain with ECDSA support
char *parse_x509_chain( unsigned char *buffer,
int pdu_length,
public_key_info *server_public_key )
{
switch ( server_public_key->algorithm )
{
case ecdsa:
set_huge( &server_public_key->ecdsa_curve.a, 0 );
set_huge( &server_public_key->ecdsa_curve.b, 0 );
set_huge( &server_public_key->ecdsa_curve.G.x, 0 );
set_huge( &server_public_key->ecdsa_curve.G.y, 0 );
set_huge( &server_public_key->ecdsa_curve.p, 0 );
set_huge( &server_public_key->ecdsa_curve.n, 0 );
set_huge( &server_public_key->ecdsa_public_key.x, 0 );
set_huge( &server_public_key->ecdsa_public_key.y, 0 );
copy_huge( &server_public_key->ecdsa_curve.a,
&certificate.tbsCertificate.subjectPublicKeyInfo.ecdsa_curve.a );
copy_huge( &server_public_key->ecdsa_curve.b,
&certificate.tbsCertificate.subjectPublicKeyInfo.ecdsa_curve.b );
copy_huge( &server_public_key->ecdsa_curve.G.x,
&certificate.tbsCertificate.subjectPublicKeyInfo.ecdsa_curve.G.x );
copy_huge( &server_public_key->ecdsa_curve.G.y,
&certificate.tbsCertificate.subjectPublicKeyInfo.ecdsa_curve.G.y );
copy_huge( &server_public_key->ecdsa_curve.p,
&certificate.tbsCertificate.subjectPublicKeyInfo.ecdsa_curve.p );
(Continued)
 
Search WWH ::




Custom Search