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)
| 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. |
| 20 | func 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. |
no outgoing calls
no test coverage detected