1EVP_SIGNINIT(3ossl) OpenSSL EVP_SIGNINIT(3ossl)
2
3
4
6 EVP_SignInit, EVP_SignInit_ex, EVP_SignUpdate, EVP_SignFinal_ex,
7 EVP_SignFinal - EVP signing functions
8
10 #include <openssl/evp.h>
11
12 int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
13 int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
14 int EVP_SignFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
15 EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, const char *propq);
16 int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sig, unsigned int *s,
17 EVP_PKEY *pkey);
18
19 void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type);
20
22 The EVP signature routines are a high-level interface to digital
23 signatures.
24
25 EVP_SignInit_ex() sets up signing context ctx to use digest type from
26 ENGINE impl. ctx must be created with EVP_MD_CTX_new() before calling
27 this function.
28
29 EVP_SignUpdate() hashes cnt bytes of data at d into the signature
30 context ctx. This function can be called several times on the same ctx
31 to include additional data.
32
33 EVP_SignFinal_ex() signs the data in ctx using the private key pkey and
34 places the signature in sig. The library context libctx and property
35 query propq are used when creating a context to use with the key pkey.
36 sig must be at least "EVP_PKEY_get_size(pkey)" bytes in size. s is an
37 OUT parameter, and not used as an IN parameter. The number of bytes of
38 data written (i.e. the length of the signature) will be written to the
39 integer at s, at most "EVP_PKEY_get_size(pkey)" bytes will be written.
40
41 EVP_SignFinal() is similar to EVP_SignFinal_ex() but uses default
42 values of NULL for the library context libctx and the property query
43 propq.
44
45 EVP_SignInit() initializes a signing context ctx to use the default
46 implementation of digest type.
47
49 EVP_SignInit_ex(), EVP_SignUpdate(), EVP_SignFinal_ex() and
50 EVP_SignFinal() return 1 for success and 0 for failure.
51
52 The error codes can be obtained by ERR_get_error(3).
53
55 The EVP interface to digital signatures should almost always be used in
56 preference to the low-level interfaces. This is because the code then
57 becomes transparent to the algorithm used and much more flexible.
58
59 When signing with DSA private keys the random number generator must be
60 seeded. If the automatic seeding or reseeding of the OpenSSL CSPRNG
61 fails due to external circumstances (see RAND(7)), the operation will
62 fail. This requirement does not hold for RSA signatures.
63
64 The call to EVP_SignFinal() internally finalizes a copy of the digest
65 context. This means that calls to EVP_SignUpdate() and EVP_SignFinal()
66 can be called later to digest and sign additional data.
67
68 Since only a copy of the digest context is ever finalized the context
69 must be cleaned up after use by calling EVP_MD_CTX_free() or a memory
70 leak will occur.
71
73 Older versions of this documentation wrongly stated that calls to
74 EVP_SignUpdate() could not be made after calling EVP_SignFinal().
75
76 Since the private key is passed in the call to EVP_SignFinal() any
77 error relating to the private key (for example an unsuitable key and
78 digest combination) will not be indicated until after potentially large
79 amounts of data have been passed through EVP_SignUpdate().
80
81 It is not possible to change the signing parameters using these
82 function.
83
84 The previous two bugs are fixed in the newer EVP_SignDigest*()
85 function.
86
88 EVP_PKEY_get_size(3), EVP_PKEY_get_bits(3),
89 EVP_PKEY_get_security_bits(3), EVP_VerifyInit(3), EVP_DigestInit(3),
90 evp(7), HMAC(3), MD2(3), MD5(3), MDC2(3), RIPEMD160(3), SHA1(3),
91 openssl-dgst(1)
92
94 The function EVP_SignFinal_ex() was added in OpenSSL 3.0.
95
97 Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
98
99 Licensed under the Apache License 2.0 (the "License"). You may not use
100 this file except in compliance with the License. You can obtain a copy
101 in the file LICENSE in the source distribution or at
102 <https://www.openssl.org/source/license.html>.
103
104
105
1063.0.5 2022-11-01 EVP_SIGNINIT(3ossl)