|
@@ -1,5 +1,8 @@
|
|
import ctypes
|
|
import ctypes
|
|
|
|
|
|
|
|
+SIGN_LIB_NAME = 'libgmsign.so'
|
|
|
|
+VERIFY_LIB_NAME = 'libgmsign.so'
|
|
|
|
+
|
|
def get_sign(raw_data: str) -> (str, str):
|
|
def get_sign(raw_data: str) -> (str, str):
|
|
"""
|
|
"""
|
|
获取签名值
|
|
获取签名值
|
|
@@ -7,7 +10,7 @@ def get_sign(raw_data: str) -> (str, str):
|
|
:return: tuple(str,str):(签名值base64字符串,公钥base64字符串)
|
|
:return: tuple(str,str):(签名值base64字符串,公钥base64字符串)
|
|
"""
|
|
"""
|
|
# 加载共享库
|
|
# 加载共享库
|
|
- lib = ctypes.CDLL('libgmsign.so')
|
|
|
|
|
|
+ lib = ctypes.CDLL(SIGN_LIB_NAME)
|
|
|
|
|
|
# 定义函数的参数和返回类型
|
|
# 定义函数的参数和返回类型
|
|
# 签名函数签名如下:
|
|
# 签名函数签名如下:
|
|
@@ -36,7 +39,7 @@ def verify_sign(raw_data: str, sign_data: str, public_key: str) -> bool:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
# 加载共享库
|
|
# 加载共享库
|
|
- lib = ctypes.CDLL('libgmsign.so')
|
|
|
|
|
|
+ lib = ctypes.CDLL(VERIFY_LIB_NAME)
|
|
# 验签函数签名如下:
|
|
# 验签函数签名如下:
|
|
# int sign_verify(char *content, char *sign_value, char *public_key)
|
|
# int sign_verify(char *content, char *sign_value, char *public_key)
|
|
lib.sign_verify.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
|
|
lib.sign_verify.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
|