Open rekeys if nonce[2:8] is different than in the last call, masks the nonce, and calls Open for aes128gcm.
(dst, nonce, ciphertext, additionalData []byte)
| 78 | // Open rekeys if nonce[2:8] is different than in the last call, masks the nonce, |
| 79 | // and calls Open for aes128gcm. |
| 80 | func (s *rekeyAEAD) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { |
| 81 | if err := s.rekeyIfRequired(nonce); err != nil { |
| 82 | return nil, err |
| 83 | } |
| 84 | maskNonce(s.nonceBuf, nonce, s.nonceMask) |
| 85 | return s.gcmAEAD.Open(dst, s.nonceBuf, ciphertext, additionalData) |
| 86 | } |
| 87 | |
| 88 | // rekeyIfRequired creates a new aes128gcm AEAD if the existing AEAD is nil |
| 89 | // or cannot be used with given nonce. |