Blame doc/man3/EVP_SignInit.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
EVP_SignInit, EVP_SignInit_ex, EVP_SignUpdate, EVP_SignFinal
Packit c4476c
- EVP signing functions
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/evp.h>
Packit c4476c
Packit c4476c
 int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
Packit c4476c
 int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
Packit c4476c
 int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sig, unsigned int *s, EVP_PKEY *pkey);
Packit c4476c
Packit c4476c
 void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
The EVP signature routines are a high level interface to digital
Packit c4476c
signatures.
Packit c4476c
Packit c4476c
EVP_SignInit_ex() sets up signing context I<ctx> to use digest
Packit c4476c
I<type> from B<ENGINE> I<impl>. I<ctx> must be created with
Packit c4476c
EVP_MD_CTX_new() before calling this function.
Packit c4476c
Packit c4476c
EVP_SignUpdate() hashes I<cnt> bytes of data at I<d> into the
Packit c4476c
signature context I<ctx>. This function can be called several times on the
Packit c4476c
same I<ctx> to include additional data.
Packit c4476c
Packit c4476c
EVP_SignFinal() signs the data in I<ctx> using the private key I<pkey> and
Packit c4476c
places the signature in I<sig>. I<sig> must be at least C<EVP_PKEY_size(pkey)>
Packit c4476c
bytes in size. I<s> is an OUT parameter, and not used as an IN parameter.
Packit c4476c
The number of bytes of data written (i.e. the length of the signature)
Packit c4476c
will be written to the integer at I<s>, at most C<EVP_PKEY_size(pkey)> bytes
Packit c4476c
will be written.
Packit c4476c
Packit c4476c
EVP_SignInit() initializes a signing context I<ctx> to use the default
Packit c4476c
implementation of digest I<type>.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
EVP_SignInit_ex(), EVP_SignUpdate() and EVP_SignFinal() return 1
Packit c4476c
for success and 0 for failure.
Packit c4476c
Packit c4476c
The error codes can be obtained by L<ERR_get_error(3)>.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
The B<EVP> interface to digital signatures should almost always be used in
Packit c4476c
preference to the low level interfaces. This is because the code then becomes
Packit c4476c
transparent to the algorithm used and much more flexible.
Packit c4476c
Packit c4476c
When signing with DSA private keys the random number generator must be seeded.
Packit c4476c
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
Packit c4476c
external circumstances (see L<RAND(7)>), the operation will fail.
Packit c4476c
This requirement does not hold for RSA signatures.
Packit c4476c
Packit c4476c
The call to EVP_SignFinal() internally finalizes a copy of the digest context.
Packit c4476c
This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called
Packit c4476c
later to digest and sign additional data.
Packit c4476c
Packit c4476c
Since only a copy of the digest context is ever finalized the context must
Packit c4476c
be cleaned up after use by calling EVP_MD_CTX_free() or a memory leak
Packit c4476c
will occur.
Packit c4476c
Packit c4476c
=head1 BUGS
Packit c4476c
Packit c4476c
Older versions of this documentation wrongly stated that calls to
Packit c4476c
EVP_SignUpdate() could not be made after calling EVP_SignFinal().
Packit c4476c
Packit c4476c
Since the private key is passed in the call to EVP_SignFinal() any error
Packit c4476c
relating to the private key (for example an unsuitable key and digest
Packit c4476c
combination) will not be indicated until after potentially large amounts of
Packit c4476c
data have been passed through EVP_SignUpdate().
Packit c4476c
Packit c4476c
It is not possible to change the signing parameters using these function.
Packit c4476c
Packit c4476c
The previous two bugs are fixed in the newer EVP_SignDigest*() function.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<EVP_PKEY_size(3)>, L<EVP_PKEY_bits(3)>, L<EVP_PKEY_security_bits(3)>,
Packit c4476c
L<EVP_VerifyInit(3)>,
Packit c4476c
L<EVP_DigestInit(3)>,
Packit c4476c
L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
Packit c4476c
L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
Packit c4476c
L<SHA1(3)>, L<dgst(1)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut