Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit e825f73

Browse files
authored
Add openssl example for registration HMAC (#13472)
Signed-off-by: James Barton <[email protected]>
1 parent 953df2a commit e825f73

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

changelog.d/13472.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `openssl` example for generating registration HMAC digest.

docs/admin_api/register_api.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,24 @@ As an example:
4646
The MAC is the hex digest output of the HMAC-SHA1 algorithm, with the key being
4747
the shared secret and the content being the nonce, user, password, either the
4848
string "admin" or "notadmin", and optionally the user_type
49-
each separated by NULs. For an example of generation in Python:
49+
each separated by NULs.
50+
51+
Here is an easy way to generate the HMAC digest if you have Bash and OpenSSL:
52+
53+
```bash
54+
# Update these values and then paste this code block into a bash terminal
55+
nonce='thisisanonce'
56+
username='pepper_roni'
57+
password='pizza'
58+
admin='admin'
59+
secret='shared_secret'
60+
61+
printf '%s\0%s\0%s\0%s' "$nonce" "$username" "$password" "$admin" |
62+
openssl sha1 -hmac "$secret" |
63+
awk '{print $2}'
64+
```
65+
66+
For an example of generation in Python:
5067

5168
```python
5269
import hmac, hashlib
@@ -70,4 +87,4 @@ def generate_mac(nonce, user, password, admin=False, user_type=None):
7087
mac.update(user_type.encode('utf8'))
7188

7289
return mac.hexdigest()
73-
```
90+
```

0 commit comments

Comments
 (0)