Loading...
Searching...
No Matches
lime_keys.hpp
Go to the documentation of this file.
/*
lime_keys.hpp
@author Johan Pascal
@copyright Copyright (C) 2017 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef lime_keys_hpp
#define lime_keys_hpp
#include <algorithm> //std::copy_n
#include <array>
#include <iterator>
#include "lime/lime.hpp"
namespace lime {
// Data structure type enumerations
enum class Xtype {publicKey, privateKey, sharedSecret};
enum class DSAtype {publicKey, privateKey, signature};
/* define needed constant for the curves: self identificatio(used in DB and as parameter from lib users, data structures sizes)*/
/* These structure are used as template argument to enable support for different key Exchznge and signature Algorithms */
struct C255 {
static constexpr lime::CurveId curveId() {return lime::CurveId::c25519;};
static constexpr size_t Xsize(lime::Xtype dataType) {return 32;};
static constexpr size_t DSAsize(lime::DSAtype dataType) {return (dataType != lime::DSAtype::signature)?32:64;};
};
struct C448 {
static constexpr lime::CurveId curveId() {return lime::CurveId::c448;};
static constexpr size_t Xsize(lime::Xtype dataType) {return 56;};
static constexpr size_t DSAsize(lime::DSAtype dataType) {return (dataType != lime::DSAtype::signature)?57:114;};
};
// Hash function defines
struct SHA512 {
static constexpr size_t ssize() {return 64;}
};
// AEAD function defines
struct AES256GCM {
static constexpr size_t keySize(void) {return 32;};
static constexpr size_t tagSize(void) {return 16;};
};
}
#endif /* lime_keys_hpp */
lime.hpp
lime
Definition lime.cpp:30
lime::DSAtype
DSAtype
List of data types used by Signature algorithm.
Definition lime_keys.hpp:39
lime::DSAtype::signature
@ signature
Definition lime_keys.hpp:39
lime::Xtype
Xtype
List of data types used by key Echange algorithm.
Definition lime_keys.hpp:34
lime::Xtype::sharedSecret
@ sharedSecret
Definition lime_keys.hpp:34
lime::Xtype::privateKey
@ privateKey
Definition lime_keys.hpp:34
lime::Xtype::publicKey
@ publicKey
Definition lime_keys.hpp:34
lime::CurveId
CurveId
Definition lime.hpp:35
lime::CurveId::c448
@ c448
Definition lime.hpp:38
lime::CurveId::c25519
@ c25519
Definition lime.hpp:37
lime::AES256GCM
AES256GCM buffers size definition.
Definition lime_keys.hpp:83
lime::AES256GCM::keySize
static constexpr size_t keySize(void)
key size is 32 bytes
Definition lime_keys.hpp:85
lime::AES256GCM::tagSize
static constexpr size_t tagSize(void)
we use authentication tag size of 16 bytes
Definition lime_keys.hpp:87
lime::C255
curve 25519 data types size definition
Definition lime_keys.hpp:49
lime::C255::Xsize
static constexpr size_t Xsize(lime::Xtype dataType)
for X25519, public, private and shared secret have the same length: 32 bytes
Definition lime_keys.hpp:53
lime::C255::curveId
static constexpr lime::CurveId curveId()
the C25519 curve id using the CurveId enumeration
Definition lime_keys.hpp:51
lime::C255::DSAsize
static constexpr size_t DSAsize(lime::DSAtype dataType)
for Ed25519, public and private key have the same length: 32 bytes, signature is 64 bytes long
Definition lime_keys.hpp:55
lime::C448
curve 448-goldilocks data types size definition
Definition lime_keys.hpp:61
lime::C448::curveId
static constexpr lime::CurveId curveId()
the C448 curve id using the CurveId enumeration
Definition lime_keys.hpp:63
lime::C448::Xsize
static constexpr size_t Xsize(lime::Xtype dataType)
for X448, public, private and shared secret have the same length 56 bytes
Definition lime_keys.hpp:65
lime::C448::DSAsize
static constexpr size_t DSAsize(lime::DSAtype dataType)
for Ed448, public and private key have the same length 57 bytes, signature is 114 bytes long
Definition lime_keys.hpp:67
lime::SHA512
SHA512 buffer size definition.
Definition lime_keys.hpp:74
lime::SHA512::ssize
static constexpr size_t ssize()
maximum output size for SHA512 is 64 bytes
Definition lime_keys.hpp:76