1*e7b1675dSTing-Kang Chang// Copyright 2019 Google LLC 2*e7b1675dSTing-Kang Chang// 3*e7b1675dSTing-Kang Chang// Licensed under the Apache License, Version 2.0 (the "License"); 4*e7b1675dSTing-Kang Chang// you may not use this file except in compliance with the License. 5*e7b1675dSTing-Kang Chang// You may obtain a copy of the License at 6*e7b1675dSTing-Kang Chang// 7*e7b1675dSTing-Kang Chang// http://www.apache.org/licenses/LICENSE-2.0 8*e7b1675dSTing-Kang Chang// 9*e7b1675dSTing-Kang Chang// Unless required by applicable law or agreed to in writing, software 10*e7b1675dSTing-Kang Chang// distributed under the License is distributed on an "AS IS" BASIS, 11*e7b1675dSTing-Kang Chang// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*e7b1675dSTing-Kang Chang// See the License for the specific language governing permissions and 13*e7b1675dSTing-Kang Chang// limitations under the License. 14*e7b1675dSTing-Kang Chang// 15*e7b1675dSTing-Kang Chang//////////////////////////////////////////////////////////////////////////////// 16*e7b1675dSTing-Kang Chang 17*e7b1675dSTing-Kang Chang// Package hybrid provides implementations of the Hybrid Encryption primitive. 18*e7b1675dSTing-Kang Chang// 19*e7b1675dSTing-Kang Chang// The functionality of Hybrid Encryption is represented as a pair of 20*e7b1675dSTing-Kang Chang// interfaces: 21*e7b1675dSTing-Kang Chang// 22*e7b1675dSTing-Kang Chang// * HybridEncrypt for encryption of data 23*e7b1675dSTing-Kang Chang// * HybridDecrypt for decryption of data 24*e7b1675dSTing-Kang Chang// 25*e7b1675dSTing-Kang Chang// Implementations of these interfaces are secure against adaptive chosen 26*e7b1675dSTing-Kang Chang// ciphertext attacks. In addition to plaintext the encryption takes an extra 27*e7b1675dSTing-Kang Chang// parameter contextInfo, which usually is public data implicit from the 28*e7b1675dSTing-Kang Chang// context, but should be bound to the resulting ciphertext, i.e. the 29*e7b1675dSTing-Kang Chang// ciphertext allows for checking the integrity of contextInfo (but there are 30*e7b1675dSTing-Kang Chang// no guarantees wrt. the secrecy or authenticity of contextInfo). 31*e7b1675dSTing-Kang Changpackage hybrid 32*e7b1675dSTing-Kang Chang 33*e7b1675dSTing-Kang Changimport ( 34*e7b1675dSTing-Kang Chang "fmt" 35*e7b1675dSTing-Kang Chang 36*e7b1675dSTing-Kang Chang "github.com/google/tink/go/core/registry" 37*e7b1675dSTing-Kang Chang) 38*e7b1675dSTing-Kang Chang 39*e7b1675dSTing-Kang Changfunc init() { 40*e7b1675dSTing-Kang Chang if err := registry.RegisterKeyManager(new(hpkePublicKeyManager)); err != nil { 41*e7b1675dSTing-Kang Chang panic(fmt.Sprintf("hybrid.init() failed: %v", err)) 42*e7b1675dSTing-Kang Chang } 43*e7b1675dSTing-Kang Chang if err := registry.RegisterKeyManager(new(hpkePrivateKeyManager)); err != nil { 44*e7b1675dSTing-Kang Chang panic(fmt.Sprintf("hybrid.init() failed: %v", err)) 45*e7b1675dSTing-Kang Chang } 46*e7b1675dSTing-Kang Chang 47*e7b1675dSTing-Kang Chang if err := registry.RegisterKeyManager(new(eciesAEADHKDFPrivateKeyKeyManager)); err != nil { 48*e7b1675dSTing-Kang Chang panic(fmt.Sprintf("hybrid.init() failed: %v", err)) 49*e7b1675dSTing-Kang Chang } 50*e7b1675dSTing-Kang Chang if err := registry.RegisterKeyManager(new(eciesAEADHKDFPublicKeyKeyManager)); err != nil { 51*e7b1675dSTing-Kang Chang panic(fmt.Sprintf("hybrid.init() failed: %v", err)) 52*e7b1675dSTing-Kang Chang } 53*e7b1675dSTing-Kang Chang} 54