(key []byte, nonce []byte, ciphertext []byte, aad []byte)
| 41 | } |
| 42 | |
| 43 | func DecryptAEAD(key []byte, nonce []byte, ciphertext []byte, aad []byte) ([]byte, error) { |
| 44 | blk, err := aes.NewCipher(key) |
| 45 | if err != nil { |
| 46 | return nil, err |
| 47 | } |
| 48 | aead, err := cipher.NewGCM(blk) |
| 49 | if err != nil { |
| 50 | return nil, err |
| 51 | } |
| 52 | pt, err := aead.Open(nil, nonce, ciphertext, aad) |
| 53 | if err != nil { |
| 54 | return nil, err |
| 55 | } |
| 56 | return pt, nil |
| 57 | } |
| 58 | |
| 59 | func RandBytes(r io.Reader, n int) ([]byte, error) { |
| 60 | b := make([]byte, n) |
no outgoing calls
no test coverage detected