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

Function md_util_base64url_encode

modules/md/md_util.c:1207–1234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1205}
1206
1207const char *md_util_base64url_encode(const md_data_t *data, apr_pool_t *pool)
1208{
1209 int i, len = (int)data->len;
1210 apr_size_t slen = ((data->len+2)/3)*4 + 1; /* 0 terminated */
1211 const unsigned char *udata = (const unsigned char*)data->data;
1212 unsigned char *enc, *p = apr_pcalloc(pool, slen);
1213
1214 enc = p;
1215 for (i = 0; i < len-2; i+= 3) {
1216 *p++ = BASE64URL_CHAR( (udata[i] >> 2) );
1217 *p++ = BASE64URL_CHAR( (udata[i] << 4) + (udata[i+1] >> 4) );
1218 *p++ = BASE64URL_CHAR( (udata[i+1] << 2) + (udata[i+2] >> 6) );
1219 *p++ = BASE64URL_CHAR( (udata[i+2]) );
1220 }
1221
1222 if (i < len) {
1223 *p++ = BASE64URL_CHAR( (udata[i] >> 2) );
1224 if (i == (len - 1)) {
1225 *p++ = BASE64URL_CHARS[ ((unsigned int)udata[i] << 4) & 0x3fu ];
1226 }
1227 else {
1228 *p++ = BASE64URL_CHAR( (udata[i] << 4) + (udata[i+1] >> 4) );
1229 *p++ = BASE64URL_CHAR( (udata[i+1] << 2) );
1230 }
1231 }
1232 *p++ = '\0';
1233 return (char *)enc;
1234}
1235
1236/*******************************************************************************
1237 * link header handling

Callers 11

bn64Function · 0.85
md_crypt_sign64Function · 0.85
md_crypt_sha256_digest64Function · 0.85
md_crypt_hmac64Function · 0.85
md_cert_to_base64urlFunction · 0.85
md_cert_req_createFunction · 0.85
md_cert_get_ari_cert_idFunction · 0.85
md_jws_signFunction · 0.85
md_jws_hmacFunction · 0.85
ostat_to_jsonFunction · 0.85
init_store_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected