| 1 |
// Package crypto provides compact authenticated encryption for values that are |
| 2 |
// sent through OpenVPN clients and later accepted back by the server. |
| 3 |
// |
| 4 |
// The package uses AES-256-GCM authenticated encryption. The serialized |
| 5 |
// ciphertext layout is: |
| 6 |
// |
| 7 |
// 12-byte random nonce || ciphertext || 16-byte GCM tag |
| 8 |
// |
| 9 |
// Go generates and prepends a fresh random nonce for each encryption. |
| 10 |
// Authentication is verified before plaintext is returned, so modified |
| 11 |
// client-controlled data is rejected before it is interpreted. The AEAD key is |
| 12 |
// derived from the configured secret with HKDF-SHA256. |
| 13 |
// |
| 14 |
// EncryptBytesWithTime wraps the encrypted payload with an issued timestamp and |
| 15 |
// encodes the result using unpadded URL-safe base64. DecryptBytesWithTime and |
| 16 |
// DecryptStringWithTime only accept that raw URL-base64 form, reject oversized |
| 17 |
// input, verify integrity, and reject data older than the cipher's configured |
| 18 |
// maximum age or issued more than five seconds in the future. |
| 19 |
// DecryptStringWithTimeInto lets callers provide reusable destination storage. |
| 20 |
package crypto |