From 04b56b5d3f8dab09dafb048ae889eb3fcbc3509d Mon Sep 17 00:00:00 2001 From: James Barton Date: Sun, 7 Aug 2022 10:40:07 -0500 Subject: [PATCH 1/2] Add openssl example for registration hmac --- changelog.d/13472.doc | 1 + docs/admin_api/register_api.md | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 changelog.d/13472.doc diff --git a/changelog.d/13472.doc b/changelog.d/13472.doc new file mode 100644 index 000000000000..be74c9cb0a2e --- /dev/null +++ b/changelog.d/13472.doc @@ -0,0 +1 @@ +Add openssl example for generating registration hmac digest. diff --git a/docs/admin_api/register_api.md b/docs/admin_api/register_api.md index c346090bb175..d7b7cf6a768b 100644 --- a/docs/admin_api/register_api.md +++ b/docs/admin_api/register_api.md @@ -46,7 +46,24 @@ As an example: The MAC is the hex digest output of the HMAC-SHA1 algorithm, with the key being the shared secret and the content being the nonce, user, password, either the string "admin" or "notadmin", and optionally the user_type -each separated by NULs. For an example of generation in Python: +each separated by NULs. + +Here is an easy way to generate the HMAC digest if you have Bash and OpenSSL: + +```bash +# Update these values and then paste this code block into a bash terminal +nonce='thisisanonce' +username='pepper_roni' +password='pizza' +admin='admin' +secret='shared_secret' + +printf '%s\0%s\0%s\0%s' "$nonce" "$username" "$password" "$admin" | + openssl sha1 -hmac "$secret" | + awk '{print $2}' +``` + +For an example of generation in Python: ```python import hmac, hashlib @@ -70,4 +87,4 @@ def generate_mac(nonce, user, password, admin=False, user_type=None): mac.update(user_type.encode('utf8')) return mac.hexdigest() -``` \ No newline at end of file +``` From 11c912178eca76347c490425762265418e87ccb1 Mon Sep 17 00:00:00 2001 From: James Barton Date: Thu, 11 Aug 2022 13:32:40 -0500 Subject: [PATCH 2/2] Minor improvements to changelog entry Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> --- changelog.d/13472.doc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13472.doc b/changelog.d/13472.doc index be74c9cb0a2e..2ff631730062 100644 --- a/changelog.d/13472.doc +++ b/changelog.d/13472.doc @@ -1 +1 @@ -Add openssl example for generating registration hmac digest. +Add `openssl` example for generating registration HMAC digest.