19670949ca
Rather than adding a new mode to EVP_PKEY_CTX, upstream chose to tie single-shot signing to EVP_MD_CTX, adding functions which combine EVP_Digest*Update and EVP_Digest*Final. This adds a weird vestigial EVP_MD_CTX and makes the signing digest parameter non-uniform, slightly complicating things. But it means APIs like X509_sign_ctx can work without modification. Align with upstream's APIs. This required a bit of fiddling around evp_test.cc. For consistency and to avoid baking details of parameter input order, I made it eagerly read all inputs before calling SetupContext. Otherwise which attributes are present depend a lot on the shape of the API we use---notably the NO_DEFAULT_DIGEST tests for RSA switch to failing before consuming an input, which is odd. (This only matters because we have some tests which expect the operation to abort the operation early with parameter errors and match against Error. Those probably should not use FileTest to begin with, but I'll tease that apart a later time.) Upstream also named NID_Ed25519 as NID_ED25519, even though the algorithm is normally stylized as "Ed25519". Switch it to match. Change-Id: Id6c8f5715930038e754de50338924d044e908045 Reviewed-on: https://boringssl-review.googlesource.com/17044 Commit-Queue: Steven Valdez <svaldez@google.com> Reviewed-by: Steven Valdez <svaldez@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
67 lines
2.6 KiB
C
67 lines
2.6 KiB
C
/* Copyright (c) 2016, Google Inc.
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
|
|
#ifndef OPENSSL_HEADER_X509_INTERNAL_H
|
|
#define OPENSSL_HEADER_X509_INTERNAL_H
|
|
|
|
#include <openssl/base.h>
|
|
#include <openssl/evp.h>
|
|
#include <openssl/x509.h>
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
/* RSA-PSS functions. */
|
|
|
|
/* x509_rsa_pss_to_ctx configures |ctx| for an RSA-PSS operation based on
|
|
* signature algorithm parameters in |sigalg| (which must have type
|
|
* |NID_rsassaPss|) and key |pkey|. It returns one on success and zero on
|
|
* error. */
|
|
int x509_rsa_pss_to_ctx(EVP_MD_CTX *ctx, X509_ALGOR *sigalg, EVP_PKEY *pkey);
|
|
|
|
/* x509_rsa_pss_to_ctx sets |algor| to the signature algorithm parameters for
|
|
* |ctx|, which must have been configured for an RSA-PSS signing operation. It
|
|
* returns one on success and zero on error. */
|
|
int x509_rsa_ctx_to_pss(EVP_MD_CTX *ctx, X509_ALGOR *algor);
|
|
|
|
/* x509_print_rsa_pss_params prints a human-readable representation of RSA-PSS
|
|
* parameters in |sigalg| to |bp|. It returns one on success and zero on
|
|
* error. */
|
|
int x509_print_rsa_pss_params(BIO *bp, const X509_ALGOR *sigalg, int indent,
|
|
ASN1_PCTX *pctx);
|
|
|
|
|
|
/* Signature algorithm functions. */
|
|
|
|
/* x509_digest_sign_algorithm encodes the signing parameters of |ctx| as an
|
|
* AlgorithmIdentifer and saves the result in |algor|. It returns one on
|
|
* success, or zero on error. */
|
|
int x509_digest_sign_algorithm(EVP_MD_CTX *ctx, X509_ALGOR *algor);
|
|
|
|
/* x509_digest_verify_init sets up |ctx| for a signature verification operation
|
|
* with public key |pkey| and parameters from |algor|. The |ctx| argument must
|
|
* have been initialised with |EVP_MD_CTX_init|. It returns one on success, or
|
|
* zero on error. */
|
|
int x509_digest_verify_init(EVP_MD_CTX *ctx, X509_ALGOR *sigalg,
|
|
EVP_PKEY *pkey);
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
} /* extern C */
|
|
#endif
|
|
|
|
#endif /* OPENSSL_HEADER_X509_INTERNAL_H */
|