mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 08:56:17 +08:00
@@ -1,12 +1,52 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
project(GmSSL)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
option(NO_RC4 "Option For Not Compile RC4" OFF)
|
||||
option(NO_MD5 "Option For Not Compile RC4" OFF)
|
||||
option(NO_AES "Option For Not Compile RC4" OFF)
|
||||
option(NO_DES "Option For Not Compile RC4" OFF)
|
||||
option(NO_CHACHA20 "Option For Not Compile RC4" OFF)
|
||||
option(NO_SHA1 "Option For Not Compile RC4" OFF)
|
||||
option(NO_SHA2 "Option For Not Compile RC4" OFF)
|
||||
|
||||
if (NO_RC4)
|
||||
add_definitions(-DNO_RC4)
|
||||
endif()
|
||||
|
||||
if (NO_MD5)
|
||||
add_definitions(-DNO_MD5)
|
||||
endif()
|
||||
|
||||
if (NO_AES)
|
||||
add_definitions(-DNO_AES)
|
||||
endif()
|
||||
|
||||
if (NO_DES)
|
||||
add_definitions(-DNO_DES)
|
||||
endif()
|
||||
|
||||
if (NO_CHACHA20)
|
||||
add_definitions(-DNO_CHACHA20)
|
||||
endif()
|
||||
|
||||
if (NO_SHA1)
|
||||
add_definitions(-DNO_SHA1)
|
||||
endif()
|
||||
|
||||
if (NO_SHA2)
|
||||
add_definitions(-DNO_SHA2)
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
|
||||
add_library(
|
||||
gmssl
|
||||
|
||||
SHARED
|
||||
|
||||
src/hex.c
|
||||
src/debug.c
|
||||
src/rand.c
|
||||
@@ -64,8 +104,7 @@ add_library(
|
||||
src/cms.c
|
||||
|
||||
)
|
||||
|
||||
target_include_directories (gmssl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
SET_TARGET_PROPERTIES(gmssl PROPERTIES VERSION 3.0 SOVERSION 3)
|
||||
|
||||
# tools
|
||||
add_executable (digest tools/digest.c)
|
||||
@@ -115,6 +154,7 @@ target_link_libraries (tlcp_server LINK_PUBLIC gmssl)
|
||||
|
||||
add_executable (tls12_client tools/tls12_client.c)
|
||||
target_link_libraries (tls12_client LINK_PUBLIC gmssl)
|
||||
|
||||
add_executable (tls12_server tools/tls12_server.c)
|
||||
target_link_libraries (tls12_server LINK_PUBLIC gmssl)
|
||||
|
||||
@@ -122,18 +162,25 @@ target_link_libraries (tls12_server LINK_PUBLIC gmssl)
|
||||
# tests
|
||||
add_executable(sm2test tests/sm2test.c)
|
||||
target_link_libraries (sm2test LINK_PUBLIC gmssl)
|
||||
|
||||
add_executable(sm2asn1test tests/sm2asn1test.c)
|
||||
target_link_libraries (sm2asn1test LINK_PUBLIC gmssl)
|
||||
|
||||
add_executable(sm3test tests/sm3test.c)
|
||||
target_link_libraries (sm3test LINK_PUBLIC gmssl)
|
||||
|
||||
if (!NO_MD5)
|
||||
add_executable(md5test tests/md5test.c)
|
||||
target_link_libraries (md5test LINK_PUBLIC gmssl)
|
||||
endif()
|
||||
|
||||
if (!NO_SHA1)
|
||||
add_executable(sha1test tests/sha1test.c)
|
||||
target_link_libraries (sha1test LINK_PUBLIC gmssl)
|
||||
endif()
|
||||
|
||||
|
||||
if (!NO_SHA2)
|
||||
add_executable(sha224test tests/sha224test.c)
|
||||
target_link_libraries (sha224test LINK_PUBLIC gmssl)
|
||||
|
||||
@@ -145,6 +192,8 @@ target_link_libraries (sha384test LINK_PUBLIC gmssl)
|
||||
|
||||
add_executable(sha512test tests/sha512test.c)
|
||||
target_link_libraries (sha512test LINK_PUBLIC gmssl)
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(hmactest tests/hmactest.c)
|
||||
target_link_libraries (hmactest LINK_PUBLIC gmssl)
|
||||
@@ -163,23 +212,32 @@ target_link_libraries (sm4cbctest LINK_PUBLIC gmssl)
|
||||
add_executable(zuctest tests/zuctest.c)
|
||||
target_link_libraries (zuctest LINK_PUBLIC gmssl)
|
||||
|
||||
if (!NO_AES)
|
||||
add_executable(aestest tests/aestest.c)
|
||||
target_link_libraries (aestest LINK_PUBLIC gmssl)
|
||||
endif()
|
||||
|
||||
if (!NO_RC4)
|
||||
add_executable(rc4test tests/rc4test.c)
|
||||
target_link_libraries (rc4test LINK_PUBLIC gmssl)
|
||||
endif()
|
||||
|
||||
if (!NO_CHACHA20)
|
||||
add_executable(chacha20test tests/chacha20test.c)
|
||||
target_link_libraries (chacha20test LINK_PUBLIC gmssl)
|
||||
endif()
|
||||
|
||||
add_executable(hash_drbgtest tests/hash_drbgtest.c)
|
||||
target_link_libraries (hash_drbgtest LINK_PUBLIC gmssl)
|
||||
|
||||
if (!NO_SHA1)
|
||||
add_executable(pbkdf2test tests/pbkdf2test.c)
|
||||
target_link_libraries (pbkdf2test LINK_PUBLIC gmssl)
|
||||
|
||||
add_executable(pkcs8test tests/pkcs8test.c)
|
||||
target_link_libraries (pkcs8test LINK_PUBLIC gmssl)
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(oidtest tests/oidtest.c)
|
||||
target_link_libraries (oidtest LINK_PUBLIC gmssl)
|
||||
@@ -199,3 +257,16 @@ target_link_libraries (cmstest LINK_PUBLIC gmssl)
|
||||
#add_executable(tlstest tests/tlstest.c)
|
||||
#target_link_libraries (tlstest LINK_PUBLIC gmssl)
|
||||
|
||||
# 安装可执行文件
|
||||
INSTALL(TARGETS digest certview certgen certverify reqgen sm3sum sm2gen sm2sign sm2verify sm2encrypt sm2decrypt pkcs8gen sm2view pkcs8view tlcp_client tlcp_server tls12_client tls12_server
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
# 安装动态库
|
||||
INSTALL(TARGETS gmssl
|
||||
LIBRARY DESTINATION lib
|
||||
)
|
||||
#安装头文件
|
||||
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/gmssl
|
||||
DESTINATION include
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NO_AES
|
||||
|
||||
#ifndef GMSSL_AES_H
|
||||
#define GMSSL_AES_H
|
||||
@@ -89,3 +90,4 @@ void aes_decrypt(const AES_KEY *aes_key, const uint8_t in[AES_BLOCK_SIZE], uint8
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#ifndef GMSSL_ASN1_H
|
||||
#define GMSSL_ASN1_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NO_CHACHA20
|
||||
|
||||
/* RFC 8439 "ChaCha20 and Poly1305 for IETF Protocols" */
|
||||
|
||||
#ifndef GMSSL_CHACHA20_H
|
||||
@@ -95,3 +97,4 @@ void chacha20_generate_keystream(CHACHA20_STATE *state,
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NO_DES
|
||||
|
||||
/* FIPS PUB 46-3 "Data Encryption Standard (DES)" */
|
||||
|
||||
#ifndef GMSSL_DES_H
|
||||
@@ -93,3 +95,4 @@ void des_ede_encrypt(DES_EDE_KEY *key, const unsigned char in[8], unsigned char
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -55,6 +55,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum {
|
||||
OID_undef = 0,
|
||||
//OID_aes,
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NO_RC4
|
||||
|
||||
#ifndef GMSSL_RC4_H
|
||||
#define GMSSL_RC4_H
|
||||
@@ -54,6 +55,7 @@
|
||||
#define RC4_MIN_KEY_BITS 40
|
||||
#define RC4_STATE_NUM_WORDS 256
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -73,3 +75,5 @@ void rc4_generate_keystream(RC4_STATE *state, size_t outlen, uint8_t *out);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -47,6 +47,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_AES
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -478,3 +479,4 @@ void aes_decrypt(const AES_KEY *aes_key, const uint8_t in[16], uint8_t out[16])
|
||||
|
||||
memset(state, 0, sizeof(state));
|
||||
}
|
||||
#endif
|
||||
@@ -46,6 +46,7 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NO_CHACHA20
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -121,3 +122,4 @@ void chacha20_generate_keystream(CHACHA20_STATE *state, unsigned int counts, uns
|
||||
state->d[12]++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -46,6 +46,8 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NO_DES
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -265,3 +267,4 @@ void des_encrypt(DES_KEY *key, const unsigned char in[DES_BLOCK_SIZE],
|
||||
|
||||
PUTU64(out, T);
|
||||
}
|
||||
#endif
|
||||
@@ -45,10 +45,13 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef NO_RC4
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#include <gmssl/rc4.h>
|
||||
|
||||
void rc4_set_key(RC4_STATE *state, const unsigned char *key, size_t keylen)
|
||||
@@ -115,3 +118,5 @@ unsigned char rc4_generate_keybyte(RC4_STATE *state)
|
||||
rc4_generate_keystream(state, 1, out);
|
||||
return out[0];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user