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 internalregistry 18 19import ( 20 "io" 21 22 "google.golang.org/protobuf/proto" 23 "github.com/google/tink/go/core/registry" 24 tinkpb "github.com/google/tink/go/proto/tink_go_proto" 25) 26 27// DerivableKeyManager is a special type of KeyManager that can derive new keys. 28type DerivableKeyManager interface { 29 registry.KeyManager 30 31 // KeyMaterialType returns the key material type of the key manager. 32 KeyMaterialType() tinkpb.KeyData_KeyMaterialType 33 34 // DeriveKey derives a new key from serializedKeyFormat and pseudorandomness. 35 // 36 // Note: The given parameter pseudorandomness may only produce a finite amount 37 // of randomness. Implementions must obtain the pseudorandom bytes needed 38 // before producing the key. 39 DeriveKey(serializedKeyFormat []byte, pseudorandomness io.Reader) (proto.Message, error) 40} 41