pboc sm2 签名,验签脚本

var hash_result
var r
var s
var tmp
var tmp_pub
static static_prompt = "国密sm2 签名 验签" position = 0% width = 100% height = 1
crlf
static static_sm2_public_key = "publickey" position = 0% width = 100% height = 1
crlf
edit sm2_public_key filename = "sm2_public_key" position = 0% width = 100% height = 2
crlf
static static_sm2_private_key = "privatekey" position = 0% width = 100% height = 1
crlf
edit sm2_private_key filename = "sm2_private_key" position = 0% width = 100% height = 2
crlf
static static_0002 = "---------------------------------" position = 0% width = 100% height = 1
crlf
static static_sm2_data = "签名数据" position = 0% width = 49% height = 1
crlf
edit sm2_sign_data filename = "sm2_sign_data" position = 0% width = 100% height = 2
crlf
static static_0001 = "---------------------------------" position = 0% width = 100% height = 1
crlf
static static_sm2_sign = "签名结果(R&& S)0x40字节" position = 0% width = 49% height = 1
crlf
edit sm2_sign filename = "sm2_sign" position = 0% width = 100% height = 2
crlf
static static_sm2_sign_result = "verifyresult (00 success, other failure)" position = 0% width = 100% height = 1
crlf
edit sm2_sign_verify_result filename = "sm2_sign_verify_result" position = 0% width = 100% height = 1
crlf
button sm2_sign_verify = "验签" positiont = 50% width = 40% height = 1
crlf
button sm2_sign_action = "签名" positiont = 50% width = 40% height = 1
crlf
function sm2_sign_verify
    r = left ( $sm2_sign , 20 )
    s = right ( $sm2_sign , 20 )
    tmp = 00 80
    tmp = $tmp 31323334353637383132333435363738
    tmp = $tmp FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC
    tmp = $tmp 28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93
    tmp = $tmp 32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7
    tmp = $tmp BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0
    tmp = $tmp $sm2_public_key
    tmp = sm3_256_hash ( $tmp )
    tmp = $tmp $sm2_sign_data
    tmp = sm3_256_hash ( $tmp )
    sm2_sign_verify_result = sm2_sign_verify ( $sm2_public_key , $tmp , $r , $s )
end function
function sm2_sign_action
    tmp = 00 80
    tmp = $tmp 31323334353637383132333435363738
    tmp = $tmp FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC
    tmp = $tmp 28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93
    tmp = $tmp 32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7
    tmp = $tmp BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0
    tmp_pub = sm2_generate_keypair2 ( $sm2_private_key )
    tmp = $tmp $tmp_pub
    tmp = sm3_256_hash ( $tmp )
    tmp = $tmp $sm2_sign_data
    tmp = sm3_256_hash ( $tmp )
    null = clear_fifo ()
    null = sm2_sign ( $sm2_private_key , $tmp )
    tmp = read_fifo ()
    tmp = $tmp read_fifo ()
    sm2_sign = $tmp
end function

猜你喜欢

转载自blog.csdn.net/jennyvenus/article/details/19573545
sm2
今日推荐