MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / deriveAESKey

Function deriveAESKey

internal/crypto/aes.go:20–27  ·  view source on GitHub ↗

deriveAESKey derives a 32-byte AES key from the provided input keying material using HKDF-SHA256 with a fixed info string and no salt.

(ikm string)

Source from the content-addressed store, hash-verified

18// deriveAESKey derives a 32-byte AES key from the provided input keying
19// material using HKDF-SHA256 with a fixed info string and no salt.
20func deriveAESKey(ikm string) ([]byte, error) {
21 reader := hkdf.New(sha256.New, []byte(ikm), nil, []byte(hkdfInfo))
22 key := make([]byte, 32)
23 if _, err := io.ReadFull(reader, key); err != nil {
24 return nil, err
25 }
26 return key, nil
27}
28
29// EncryptAES encrypts plaintext using AES-256-GCM. The nonce is prepended to
30// the ciphertext and the result is encoded as base64 RawURL.

Callers 2

EncryptAESFunction · 0.85
DecryptAESFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected