1 /* 2 * This file is part of the openHiTLS project. 3 * 4 * openHiTLS is licensed under the Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * 8 * http://license.coscl.org.cn/MulanPSL2 9 * 10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13 * See the Mulan PSL v2 for more details. 14 */ 15 16 #ifndef DH_LOCAL_H 17 #define DH_LOCAL_H 18 19 #include "hitls_build.h" 20 #ifdef HITLS_CRYPTO_DH 21 22 #include "crypt_bn.h" 23 #include "crypt_dh.h" 24 #include "sal_atomic.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif /* __cpluscplus */ 29 30 #define DH_MIN_PBITS 768 // Minimum DH specification: 768 bits 31 #define DH_MAX_PBITS 8192 // Maximum DH specification: 8192 bits 32 #define DH_MIN_QBITS 160 // Minimum specification of DH parameter Q: 160 bits 33 34 /* DH key parameter */ 35 struct DH_Para { 36 BN_BigNum *p; 37 BN_BigNum *q; 38 BN_BigNum *g; 39 CRYPT_PKEY_ParaId id; 40 }; 41 42 /* DH key context */ 43 struct DH_Ctx { 44 BN_BigNum *x; // Private key 45 BN_BigNum *y; // Public key 46 CRYPT_DH_Para *para; // key parameter 47 BSL_SAL_RefCount references; 48 void *libCtx; 49 uint32_t flags; 50 }; 51 52 #ifdef __cplusplus 53 } 54 #endif 55 56 #endif // HITLS_CRYPTO_DH 57 58 #endif // CRYPT_DH_H 59