OpenSSL/d2i ECPKParameters

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The ECPKParameters encode and decode routines encode and parse the public parameters for an EC_GROUP structure, which represents a curve.

d2i_ECPKParameters() attempts to decode len bytes at *in. If successful a pointer to the EC_GROUP structure is returned. If an error occurred then NULL is returned. If px is not NULL then the returned structure is written to *px. If *px is not NULL then it is assumed that *px contains a valid EC_GROUP structure and an attempt is made to reuse it. If the call is successful *in is incremented to the byte following the parsed data.

i2d_ECPKParameters() encodes the structure pointed to by x into DER format. If out is not NULL is writes the DER encoded data to the buffer at *out, and increments it to point after the data just written. If the return value is negative an error occurred, otherwise it returns the length of the encoded data.

If *out is NULL memory will be allocated for a buffer and the encoded data written to it. In this case *out is not incremented and it points to the start of the data just written.

d2i_ECPKParameters_bio() is similar to d2i_ECPKParameters() except it attempts to parse data from BIO bp.

d2i_ECPKParameters_fp() is similar to d2i_ECPKParameters() except it attempts to parse data from FILE pointer fp.

i2d_ECPKParameters_bio() is similar to i2d_ECPKParameters() except it writes the encoding of the structure x to BIO bp and it returns 1 for success and 0 for failure.

i2d_ECPKParameters_fp() is similar to i2d_ECPKParameters() except it writes the encoding of the structure x to BIO bp and it returns 1 for success and 0 for failure.

These functions are very similar to the X509 functions described on the OpenSSL d2i_X509 manual page, where further notes and examples are available.

The ECPKParameters_print and ECPKParameters_print_fp functions print a human-readable output of the public parameters of the EC_GROUP to bp or fp. The output lines are indented by off spaces.

Return Values[edit | edit source]

d2i_ECPKParameters(), d2i_ECPKParameters_bio() and d2i_ECPKParameters_fp() return a valid EC_GROUP structure or NULL if an error occurs.

i2d_ECPKParameters() returns the number of bytes successfully encoded or a negative value if an error occurs.

i2d_ECPKParameters_bio(), i2d_ECPKParameters_fp(), ECPKParameters_print and ECPKParameters_print_fp return 1 for success and 0 if an error occurs.