lime
Lime is a C++ library implementing Open Whisper System Signal protocol
lime_keys.hpp
Go to the documentation of this file.
1 /*
2  lime_keys.hpp
3  @author Johan Pascal
4  @copyright Copyright (C) 2017 Belledonne Communications SARL
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef lime_keys_hpp
21 #define lime_keys_hpp
22 
23 #include <algorithm> //std::copy_n
24 #include <array>
25 #include <iterator>
26 #include "lime/lime.hpp"
27 
28 namespace lime {
29  // Data structure type enumerations
40 
41  /* define needed constant for the curves: self identificatio(used in DB and as parameter from lib users, data structures sizes)*/
42  /* These structure are used as template argument to enable support for different key Exchznge and signature Algorithms */
43 
49  struct C255 {
51  static constexpr lime::CurveId curveId() {return lime::CurveId::c25519;};
53  static constexpr size_t Xsize(lime::Xtype dataType) {return 32;};
55  static constexpr size_t DSAsize(lime::DSAtype dataType) {return (dataType != lime::DSAtype::signature)?32:64;};
56  };
57 
61  struct C448 {
63  static constexpr lime::CurveId curveId() {return lime::CurveId::c448;};
65  static constexpr size_t Xsize(lime::Xtype dataType) {return 56;};
67  static constexpr size_t DSAsize(lime::DSAtype dataType) {return (dataType != lime::DSAtype::signature)?57:114;};
68  };
69 
70  // Hash function defines
74  struct SHA512 {
76  static constexpr size_t ssize() {return 64;}
77  };
78 
79  // AEAD function defines
83  struct AES256GCM {
85  static constexpr size_t keySize(void) {return 32;};
87  static constexpr size_t tagSize(void) {return 16;};
88  };
89 }
90 
91 #endif /* lime_keys_hpp */
DSAtype
List of data types used by Signature algorithm.
Definition: lime_keys.hpp:39
SHA512 buffer size definition.
Definition: lime_keys.hpp:74
static constexpr size_t ssize()
maximum output size for SHA512 is 64 bytes
Definition: lime_keys.hpp:76
static constexpr size_t keySize(void)
key size is 32 bytes
Definition: lime_keys.hpp:85
curve 25519 data types size definition
Definition: lime_keys.hpp:49
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
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
Xtype
List of data types used by key Echange algorithm.
Definition: lime_keys.hpp:34
static constexpr lime::CurveId curveId()
the C448 curve id using the CurveId enumeration
Definition: lime_keys.hpp:63
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
Definition: lime.cpp:30
static constexpr size_t tagSize(void)
we use authentication tag size of 16 bytes
Definition: lime_keys.hpp:87
curve 448-goldilocks data types size definition
Definition: lime_keys.hpp:61
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
static constexpr lime::CurveId curveId()
the C25519 curve id using the CurveId enumeration
Definition: lime_keys.hpp:51
AES256GCM buffers size definition.
Definition: lime_keys.hpp:83
CurveId
Definition: lime.hpp:34