1// Copyright 2022 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14// 15//////////////////////////////////////////////////////////////////////////////// 16 17package hpke 18 19// aead is a package-internal interface for the Hybrid Public Key Encryption 20// (HPKE) authenticated encryption with associated data (AEAD). 21// 22// The HPKE RFC is available at 23// https://www.rfc-editor.org/rfc/rfc9180.html. 24type aead interface { 25 // seal performs authenticated encryption of plaintext and associatedData 26 // using key and nonce. 27 // 28 // https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2 29 seal(key, nonce, plaintext, associatedData []byte) ([]byte, error) 30 31 // open performs authenticated decryption of ciphertext and associatedData 32 // using key and nonce. 33 // 34 // https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2 35 open(key, nonce, ciphertext, associatedData []byte) ([]byte, error) 36 37 // id returns the HPKE AEAD algorithm identifier for the underlying AEAD 38 // implementation. 39 // 40 // https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3 41 id() uint16 42 43 // keyLength returns the length of the key. 44 keyLength() int 45 46 // nonceLength returns the length of the nonce. 47 nonceLength() int 48} 49