MCPcopy Create free account
hub / github.com/apache/httpd / md_crypt_sign64

Function md_crypt_sign64

modules/md/md_crypt.c:1075–1114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1073}
1074
1075apr_status_t md_crypt_sign64(const char **psign64, md_pkey_t *pkey, apr_pool_t *p,
1076 const char *d, size_t dlen)
1077{
1078 EVP_MD_CTX *ctx = NULL;
1079 md_data_t buffer;
1080 unsigned int blen;
1081 const char *sign64 = NULL;
1082 apr_status_t rv = APR_ENOMEM;
1083
1084 md_data_pinit(&buffer, (apr_size_t)EVP_PKEY_size(pkey->pkey), p);
1085 if (buffer.data) {
1086 ctx = EVP_MD_CTX_create();
1087 if (ctx) {
1088 rv = APR_ENOTIMPL;
1089 if (EVP_SignInit_ex(ctx, EVP_sha256(), NULL)) {
1090 rv = APR_EGENERAL;
1091 if (EVP_SignUpdate(ctx, d, dlen)) {
1092 if (EVP_SignFinal(ctx, (unsigned char*)buffer.data, &blen, pkey->pkey)) {
1093 buffer.len = blen;
1094 sign64 = md_util_base64url_encode(&buffer, p);
1095 if (sign64) {
1096 rv = APR_SUCCESS;
1097 }
1098 }
1099 }
1100 }
1101 }
1102
1103 if (ctx) {
1104 EVP_MD_CTX_destroy(ctx);
1105 }
1106 }
1107
1108 if (rv != APR_SUCCESS) {
1109 md_log_perror(MD_LOG_MARK, MD_LOG_WARNING, rv, p, "signing");
1110 }
1111
1112 *psign64 = sign64;
1113 return rv;
1114}
1115
1116static apr_status_t sha256_digest(md_data_t **pdigest, apr_pool_t *p, const md_data_t *buf)
1117{

Callers 1

md_jws_signFunction · 0.85

Calls 3

md_data_pinitFunction · 0.85
md_util_base64url_encodeFunction · 0.85
md_log_perrorFunction · 0.85

Tested by

no test coverage detected