| 506 | /* Register a new account */ |
| 507 | |
| 508 | static apr_status_t get_eab(md_json_t **peab, md_acme_req_t *req, const char *kid, |
| 509 | const char *hmac64, md_pkey_t *account_key, |
| 510 | const char *url) |
| 511 | { |
| 512 | md_json_t *eab, *prot_fields, *jwk; |
| 513 | md_data_t payload, hmac_key; |
| 514 | apr_status_t rv; |
| 515 | |
| 516 | prot_fields = md_json_create(req->p); |
| 517 | md_json_sets(url, prot_fields, "url", NULL); |
| 518 | md_json_sets(kid, prot_fields, "kid", NULL); |
| 519 | |
| 520 | rv = md_jws_get_jwk(&jwk, req->p, account_key); |
| 521 | if (APR_SUCCESS != rv) goto cleanup; |
| 522 | |
| 523 | md_data_null(&payload); |
| 524 | payload.data = md_json_writep(jwk, req->p, MD_JSON_FMT_COMPACT); |
| 525 | if (!payload.data) { |
| 526 | rv = APR_EINVAL; |
| 527 | goto cleanup; |
| 528 | } |
| 529 | payload.len = strlen(payload.data); |
| 530 | |
| 531 | md_util_base64url_decode(&hmac_key, hmac64, req->p); |
| 532 | if (!hmac_key.len) { |
| 533 | rv = APR_EINVAL; |
| 534 | md_result_problem_set(req->result, rv, "apache:eab-hmac-invalid", |
| 535 | "external account binding HMAC value is not valid base64", NULL); |
| 536 | goto cleanup; |
| 537 | } |
| 538 | |
| 539 | rv = md_jws_hmac(&eab, req->p, &payload, prot_fields, &hmac_key); |
| 540 | if (APR_SUCCESS != rv) { |
| 541 | md_result_problem_set(req->result, rv, "apache:eab-hmac-fail", |
| 542 | "external account binding MAC could not be computed", NULL); |
| 543 | } |
| 544 | |
| 545 | cleanup: |
| 546 | *peab = (APR_SUCCESS == rv)? eab : NULL; |
| 547 | return rv; |
| 548 | } |
| 549 | |
| 550 | static apr_status_t on_init_acct_new(md_acme_req_t *req, void *baton) |
| 551 | { |
no test coverage detected