1*e71b7053SJung-uk Kim=pod 2*e71b7053SJung-uk Kim 3*e71b7053SJung-uk Kim=head1 NAME 4*e71b7053SJung-uk Kim 5*e71b7053SJung-uk KimX509_sign, X509_sign_ctx, X509_verify, X509_REQ_sign, X509_REQ_sign_ctx, 6*e71b7053SJung-uk KimX509_REQ_verify, X509_CRL_sign, X509_CRL_sign_ctx, X509_CRL_verify - 7*e71b7053SJung-uk Kimsign or verify certificate, certificate request or CRL signature 8*e71b7053SJung-uk Kim 9*e71b7053SJung-uk Kim=head1 SYNOPSIS 10*e71b7053SJung-uk Kim 11*e71b7053SJung-uk Kim #include <openssl/x509.h> 12*e71b7053SJung-uk Kim 13*e71b7053SJung-uk Kim int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); 14*e71b7053SJung-uk Kim int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx); 15*e71b7053SJung-uk Kim int X509_verify(X509 *a, EVP_PKEY *r); 16*e71b7053SJung-uk Kim 17*e71b7053SJung-uk Kim int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); 18*e71b7053SJung-uk Kim int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx); 19*e71b7053SJung-uk Kim int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); 20*e71b7053SJung-uk Kim 21*e71b7053SJung-uk Kim int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); 22*e71b7053SJung-uk Kim int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx); 23*e71b7053SJung-uk Kim int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); 24*e71b7053SJung-uk Kim 25*e71b7053SJung-uk Kim=head1 DESCRIPTION 26*e71b7053SJung-uk Kim 27*e71b7053SJung-uk KimX509_sign() signs certificate B<x> using private key B<pkey> and message 28*e71b7053SJung-uk Kimdigest B<md> and sets the signature in B<x>. X509_sign_ctx() also signs 29*e71b7053SJung-uk Kimcertificate B<x> but uses the parameters contained in digest context B<ctx>. 30*e71b7053SJung-uk Kim 31*e71b7053SJung-uk KimX509_verify() verifies the signature of certificate B<x> using public key 32*e71b7053SJung-uk KimB<pkey>. Only the signature is checked: no other checks (such as certificate 33*e71b7053SJung-uk Kimchain validity) are performed. 34*e71b7053SJung-uk Kim 35*e71b7053SJung-uk KimX509_REQ_sign(), X509_REQ_sign_ctx(), X509_REQ_verify(), 36*e71b7053SJung-uk KimX509_CRL_sign(), X509_CRL_sign_ctx() and X509_CRL_verify() sign and verify 37*e71b7053SJung-uk Kimcertificate requests and CRLs respectively. 38*e71b7053SJung-uk Kim 39*e71b7053SJung-uk Kim=head1 NOTES 40*e71b7053SJung-uk Kim 41*e71b7053SJung-uk KimX509_sign_ctx() is used where the default parameters for the corresponding 42*e71b7053SJung-uk Kimpublic key and digest are not suitable. It can be used to sign keys using 43*e71b7053SJung-uk KimRSA-PSS for example. 44*e71b7053SJung-uk Kim 45*e71b7053SJung-uk KimFor efficiency reasons and to work around ASN.1 encoding issues the encoding 46*e71b7053SJung-uk Kimof the signed portion of a certificate, certificate request and CRL is cached 47*e71b7053SJung-uk Kiminternally. If the signed portion of the structure is modified the encoding 48*e71b7053SJung-uk Kimis not always updated meaning a stale version is sometimes used. This is not 49*e71b7053SJung-uk Kimnormally a problem because modifying the signed portion will invalidate the 50*e71b7053SJung-uk Kimsignature and signing will always update the encoding. 51*e71b7053SJung-uk Kim 52*e71b7053SJung-uk Kim=head1 RETURN VALUES 53*e71b7053SJung-uk Kim 54*e71b7053SJung-uk KimX509_sign(), X509_sign_ctx(), X509_REQ_sign(), X509_REQ_sign_ctx(), 55*e71b7053SJung-uk KimX509_CRL_sign() and X509_CRL_sign_ctx() return the size of the signature 56*e71b7053SJung-uk Kimin bytes for success and zero for failure. 57*e71b7053SJung-uk Kim 58*e71b7053SJung-uk KimX509_verify(), X509_REQ_verify() and X509_CRL_verify() return 1 if the 59*e71b7053SJung-uk Kimsignature is valid and 0 if the signature check fails. If the signature 60*e71b7053SJung-uk Kimcould not be checked at all because it was invalid or some other error 61*e71b7053SJung-uk Kimoccurred then -1 is returned. 62*e71b7053SJung-uk Kim 63*e71b7053SJung-uk Kim=head1 SEE ALSO 64*e71b7053SJung-uk Kim 65*e71b7053SJung-uk KimL<d2i_X509(3)>, 66*e71b7053SJung-uk KimL<ERR_get_error(3)>, 67*e71b7053SJung-uk KimL<X509_CRL_get0_by_serial(3)>, 68*e71b7053SJung-uk KimL<X509_get0_signature(3)>, 69*e71b7053SJung-uk KimL<X509_get_ext_d2i(3)>, 70*e71b7053SJung-uk KimL<X509_get_extension_flags(3)>, 71*e71b7053SJung-uk KimL<X509_get_pubkey(3)>, 72*e71b7053SJung-uk KimL<X509_get_subject_name(3)>, 73*e71b7053SJung-uk KimL<X509_get_version(3)>, 74*e71b7053SJung-uk KimL<X509_NAME_add_entry_by_txt(3)>, 75*e71b7053SJung-uk KimL<X509_NAME_ENTRY_get_object(3)>, 76*e71b7053SJung-uk KimL<X509_NAME_get_index_by_NID(3)>, 77*e71b7053SJung-uk KimL<X509_NAME_print_ex(3)>, 78*e71b7053SJung-uk KimL<X509_new(3)>, 79*e71b7053SJung-uk KimL<X509V3_get_d2i(3)>, 80*e71b7053SJung-uk KimL<X509_verify_cert(3)> 81*e71b7053SJung-uk Kim 82*e71b7053SJung-uk Kim=head1 HISTORY 83*e71b7053SJung-uk Kim 84*e71b7053SJung-uk KimX509_sign(), X509_REQ_sign() and X509_CRL_sign() are available in all 85*e71b7053SJung-uk Kimversions of OpenSSL. 86*e71b7053SJung-uk Kim 87*e71b7053SJung-uk KimX509_sign_ctx(), X509_REQ_sign_ctx() and X509_CRL_sign_ctx() were first added 88*e71b7053SJung-uk Kimto OpenSSL 1.0.1. 89*e71b7053SJung-uk Kim 90*e71b7053SJung-uk Kim=head1 COPYRIGHT 91*e71b7053SJung-uk Kim 92*e71b7053SJung-uk KimCopyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 93*e71b7053SJung-uk Kim 94*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License"). You may not use 95*e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 96*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 97*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 98*e71b7053SJung-uk Kim 99*e71b7053SJung-uk Kim=cut 100