Skip to content

cmd/anubis: derive signing key from configurable secret#70

Closed
AlexanderYastrebov wants to merge 1 commit intoTecharoHQ:mainfrom
AlexanderYastrebov:secret
Closed

cmd/anubis: derive signing key from configurable secret#70
AlexanderYastrebov wants to merge 1 commit intoTecharoHQ:mainfrom
AlexanderYastrebov:secret

Conversation

@AlexanderYastrebov
Copy link
Copy Markdown
Contributor

@AlexanderYastrebov AlexanderYastrebov commented Mar 21, 2025

Add new flag that provides value for Key Derivation Function.

This enables multiple instances and restarts without invalidating existing cookies.

Fixes #32

Checklist:

  • Added a description of the changes to the [Unreleased] section of docs/docs/CHANGELOG.md
  • Tested this at least manually

@AlexanderYastrebov AlexanderYastrebov force-pushed the secret branch 2 times, most recently from 822cbf8 to 58502a3 Compare March 21, 2025 21:45
@AlexanderYastrebov AlexanderYastrebov changed the title cmd/anubis: derive key from configurable secret cmd/anubis: derive signing key from configurable secret Mar 21, 2025
Add new flag that provides value for Key Derivation Function.

This enables multiple instances and restarts without invalidating
existing cookies.

Fixes TecharoHQ#32
Comment thread cmd/anubis/main.go
Comment on lines +722 to +724
if secret != "" {
rr = hkdf.New(sha256.New, []byte(secret), nil, []byte("ed25519 signing key"))
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that secret should be a good random value (e.g. head -c 32 /dev/urandom | base64), HKDF is used for "key splitting", here to derive a signing key and maybe later to derive other keys from this (master) secret.

Alternative is to add "passphrase" flag and use password-based KDF (e.g. https://en.wikipedia.org/wiki/PBKDF2) to derive keys from it.

@Xe
Copy link
Copy Markdown
Contributor

Xe commented Mar 22, 2025

This is about to need to be refactored and/or redone, a major refactor is in place.

@AlexanderYastrebov
Copy link
Copy Markdown
Contributor Author

This is about to need to be refactored and/or redone, a major refactor is in place.

Sure, for #77 you'd need to decide on type of configuration: a struct, a with*-builder or use functional options...

@Xe
Copy link
Copy Markdown
Contributor

Xe commented Mar 22, 2025

It's using a configuration struct. Once #77 is merged it will be extended to include a keypair with one being generated if it doesn't exist.

@Xe
Copy link
Copy Markdown
Contributor

Xe commented Mar 23, 2025

I think the approach in #97 may be better. Key derivation functions from passwords like this could backfire hard, and ed25519 keys are very small.

@AlexanderYastrebov
Copy link
Copy Markdown
Contributor Author

I agree. I am exploring the idea from a bit different angle and for https://github.com/AlexanderYastrebov/bot-idp I chose to provide fixed secret in base64 RawURLEncoding format like in JWT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist Anubis ed25519 key to allow for multi-instance operation

2 participants