Add Key Encapsulation Mechanism (KEM) interface

This commit is contained in:
Hugo Pointcheval 2020-12-17 22:11:03 +01:00
parent 51d10362e9
commit 6ba8da275d

50
lib/src/kem.dart Normal file
View File

@ -0,0 +1,50 @@
// Copyright (c) 2020
// Author: Hugo Pointcheval
import 'dart:typed_data';
import 'key.dart';
enum KemMode { ENCAPSULATION, DECAPSULATION }
abstract class KeyEncapsulationMechanism {
/// Returns the standard algorithm name for this kem
String get algorithm;
/// Returns the parameters used for this kem
Object get options;
/// Returns true if kem is initialized
bool get isInitialized;
/// Returns mode used in this kem.
KemMode get mode;
/// Returns key pair used in this kem.
///
/// Can be an incomplete if just have public key
/// for example.
KeyPair get keypair;
/// Encapsulate key.
///
/// Returns an [Encapsulation].
Future<Encapsulation> encapsulate();
/// Decapsulate key.
///
/// Takes [Encapsulation] as parameter.
/// And returns plain text key as [SecretKey].
Future<SecretKey> decapsulate(Encapsulation encapsulation);
}
abstract class Encapsulation {
/// Returns the standard algorithm name used for this encapsulation
String get algorithm;
/// Returns the secret key used in this encapsulation
SecretKey get secretKey;
/// Returns the encapsulated key
Uint8List get key;
}