github.com/trustbloc/kms-go@v1.1.2/kms/api.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package kms 8 9 import ( 10 "errors" 11 "io" 12 ) 13 14 // ErrKeyNotFound is an error type that a KMS expects from the Store.Get method if no key stored under the given 15 // key ID could be found. 16 var ErrKeyNotFound = errors.New("key not found") 17 18 // CryptoBox is a libsodium crypto service used by legacy authcrypt packer. 19 // TODO remove this service when legacy packer is retired from the framework. 20 type CryptoBox interface { 21 // Easy seals a payload with a provided nonce 22 Easy(payload, nonce, theirPub []byte, myKID string) ([]byte, error) 23 // EashOpen unseals a cipherText sealed with Easy, where the nonce is provided 24 EasyOpen(cipherText, nonce, theirPub, myPub []byte) ([]byte, error) 25 // Seal seals a payload using the equivalent logic of libsodium box_seal 26 Seal(payload, theirEncPub []byte, randSource io.Reader) ([]byte, error) 27 // SealOpen decrypts a payload encrypted with Seal 28 SealOpen(cipherText, myPub []byte) ([]byte, error) 29 }