mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
增加编译控制选项
This commit is contained in:
@@ -4,8 +4,43 @@ project(GmSSL)
|
|||||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||||
|
|
||||||
include_directories(include)
|
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(
|
add_library(
|
||||||
gmssl
|
gmssl
|
||||||
@@ -119,6 +154,7 @@ target_link_libraries (tlcp_server LINK_PUBLIC gmssl)
|
|||||||
|
|
||||||
add_executable (tls12_client tools/tls12_client.c)
|
add_executable (tls12_client tools/tls12_client.c)
|
||||||
target_link_libraries (tls12_client LINK_PUBLIC gmssl)
|
target_link_libraries (tls12_client LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
add_executable (tls12_server tools/tls12_server.c)
|
add_executable (tls12_server tools/tls12_server.c)
|
||||||
target_link_libraries (tls12_server LINK_PUBLIC gmssl)
|
target_link_libraries (tls12_server LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
@@ -126,18 +162,25 @@ target_link_libraries (tls12_server LINK_PUBLIC gmssl)
|
|||||||
# tests
|
# tests
|
||||||
add_executable(sm2test tests/sm2test.c)
|
add_executable(sm2test tests/sm2test.c)
|
||||||
target_link_libraries (sm2test LINK_PUBLIC gmssl)
|
target_link_libraries (sm2test LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
add_executable(sm2asn1test tests/sm2asn1test.c)
|
add_executable(sm2asn1test tests/sm2asn1test.c)
|
||||||
target_link_libraries (sm2asn1test LINK_PUBLIC gmssl)
|
target_link_libraries (sm2asn1test LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
add_executable(sm3test tests/sm3test.c)
|
add_executable(sm3test tests/sm3test.c)
|
||||||
target_link_libraries (sm3test LINK_PUBLIC gmssl)
|
target_link_libraries (sm3test LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
|
if (!NO_MD5)
|
||||||
add_executable(md5test tests/md5test.c)
|
add_executable(md5test tests/md5test.c)
|
||||||
target_link_libraries (md5test LINK_PUBLIC gmssl)
|
target_link_libraries (md5test LINK_PUBLIC gmssl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (!NO_SHA1)
|
||||||
add_executable(sha1test tests/sha1test.c)
|
add_executable(sha1test tests/sha1test.c)
|
||||||
target_link_libraries (sha1test LINK_PUBLIC gmssl)
|
target_link_libraries (sha1test LINK_PUBLIC gmssl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if (!NO_SHA2)
|
||||||
add_executable(sha224test tests/sha224test.c)
|
add_executable(sha224test tests/sha224test.c)
|
||||||
target_link_libraries (sha224test LINK_PUBLIC gmssl)
|
target_link_libraries (sha224test LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
@@ -149,6 +192,8 @@ target_link_libraries (sha384test LINK_PUBLIC gmssl)
|
|||||||
|
|
||||||
add_executable(sha512test tests/sha512test.c)
|
add_executable(sha512test tests/sha512test.c)
|
||||||
target_link_libraries (sha512test LINK_PUBLIC gmssl)
|
target_link_libraries (sha512test LINK_PUBLIC gmssl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_executable(hmactest tests/hmactest.c)
|
add_executable(hmactest tests/hmactest.c)
|
||||||
target_link_libraries (hmactest LINK_PUBLIC gmssl)
|
target_link_libraries (hmactest LINK_PUBLIC gmssl)
|
||||||
@@ -167,23 +212,32 @@ target_link_libraries (sm4cbctest LINK_PUBLIC gmssl)
|
|||||||
add_executable(zuctest tests/zuctest.c)
|
add_executable(zuctest tests/zuctest.c)
|
||||||
target_link_libraries (zuctest LINK_PUBLIC gmssl)
|
target_link_libraries (zuctest LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
|
if (!NO_AES)
|
||||||
add_executable(aestest tests/aestest.c)
|
add_executable(aestest tests/aestest.c)
|
||||||
target_link_libraries (aestest LINK_PUBLIC gmssl)
|
target_link_libraries (aestest LINK_PUBLIC gmssl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (!NO_RC4)
|
||||||
add_executable(rc4test tests/rc4test.c)
|
add_executable(rc4test tests/rc4test.c)
|
||||||
target_link_libraries (rc4test LINK_PUBLIC gmssl)
|
target_link_libraries (rc4test LINK_PUBLIC gmssl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (!NO_CHACHA20)
|
||||||
add_executable(chacha20test tests/chacha20test.c)
|
add_executable(chacha20test tests/chacha20test.c)
|
||||||
target_link_libraries (chacha20test LINK_PUBLIC gmssl)
|
target_link_libraries (chacha20test LINK_PUBLIC gmssl)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(hash_drbgtest tests/hash_drbgtest.c)
|
add_executable(hash_drbgtest tests/hash_drbgtest.c)
|
||||||
target_link_libraries (hash_drbgtest LINK_PUBLIC gmssl)
|
target_link_libraries (hash_drbgtest LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
|
if (!NO_SHA1)
|
||||||
add_executable(pbkdf2test tests/pbkdf2test.c)
|
add_executable(pbkdf2test tests/pbkdf2test.c)
|
||||||
target_link_libraries (pbkdf2test LINK_PUBLIC gmssl)
|
target_link_libraries (pbkdf2test LINK_PUBLIC gmssl)
|
||||||
|
|
||||||
add_executable(pkcs8test tests/pkcs8test.c)
|
add_executable(pkcs8test tests/pkcs8test.c)
|
||||||
target_link_libraries (pkcs8test LINK_PUBLIC gmssl)
|
target_link_libraries (pkcs8test LINK_PUBLIC gmssl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_executable(oidtest tests/oidtest.c)
|
add_executable(oidtest tests/oidtest.c)
|
||||||
target_link_libraries (oidtest LINK_PUBLIC gmssl)
|
target_link_libraries (oidtest LINK_PUBLIC gmssl)
|
||||||
@@ -214,8 +268,5 @@ INSTALL(TARGETS gmssl
|
|||||||
#安装头文件
|
#安装头文件
|
||||||
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/gmssl
|
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/gmssl
|
||||||
DESTINATION include
|
DESTINATION include
|
||||||
PATTERN "gmssl/*"
|
|
||||||
PERMISSIONS OWNER_WRITE OWNER_READ
|
|
||||||
GROUP_READ WORLD_READ
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef NO_AES
|
||||||
|
|
||||||
#ifndef GMSSL_AES_H
|
#ifndef GMSSL_AES_H
|
||||||
#define 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
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -46,6 +46,8 @@
|
|||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef NO_CHACHA20
|
||||||
|
|
||||||
/* RFC 8439 "ChaCha20 and Poly1305 for IETF Protocols" */
|
/* RFC 8439 "ChaCha20 and Poly1305 for IETF Protocols" */
|
||||||
|
|
||||||
#ifndef GMSSL_CHACHA20_H
|
#ifndef GMSSL_CHACHA20_H
|
||||||
@@ -95,3 +97,4 @@ void chacha20_generate_keystream(CHACHA20_STATE *state,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -46,6 +46,8 @@
|
|||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef NO_DES
|
||||||
|
|
||||||
/* FIPS PUB 46-3 "Data Encryption Standard (DES)" */
|
/* FIPS PUB 46-3 "Data Encryption Standard (DES)" */
|
||||||
|
|
||||||
#ifndef GMSSL_DES_H
|
#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
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef NO_RC4
|
||||||
|
|
||||||
#ifndef GMSSL_RC4_H
|
#ifndef GMSSL_RC4_H
|
||||||
#define GMSSL_RC4_H
|
#define GMSSL_RC4_H
|
||||||
@@ -74,3 +75,5 @@ void rc4_generate_keystream(RC4_STATE *state, size_t outlen, uint8_t *out);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_AES
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.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));
|
memset(state, 0, sizeof(state));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef NO_CHACHA20
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -121,3 +122,4 @@ void chacha20_generate_keystream(CHACHA20_STATE *state, unsigned int counts, uns
|
|||||||
state->d[12]++;
|
state->d[12]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
@@ -46,6 +46,8 @@
|
|||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef NO_DES
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -265,3 +267,4 @@ void des_encrypt(DES_KEY *key, const unsigned char in[DES_BLOCK_SIZE],
|
|||||||
|
|
||||||
PUTU64(out, T);
|
PUTU64(out, T);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
@@ -45,10 +45,13 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#ifndef NO_RC4
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
#include <gmssl/rc4.h>
|
#include <gmssl/rc4.h>
|
||||||
|
|
||||||
void rc4_set_key(RC4_STATE *state, const unsigned char *key, size_t keylen)
|
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);
|
rc4_generate_keystream(state, 1, out);
|
||||||
return out[0];
|
return out[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user