File tree Expand file tree Collapse file tree 3 files changed +6
-2
lines changed Expand file tree Collapse file tree 3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
print ("GMSSL_SM4_KEY_SIZE = " .GMSSL_SM4_KEY_SIZE ."\n" );
3
3
print ("GMSSL_SM4_BLOCK_SIZE = " .GMSSL_SM4_BLOCK_SIZE ."\n" );
4
+ print ("GMSSL_SM4_CBC_IV_SIZE = " .GMSSL_SM4_CBC_IV_SIZE ."\n" );
4
5
5
6
$ key = gmssl_rand_bytes (GMSSL_SM4_KEY_SIZE );
6
- $ iv = gmssl_rand_bytes (GMSSL_SM4_BLOCK_SIZE );
7
+ $ iv = gmssl_rand_bytes (GMSSL_SM4_CBC_IV_SIZE );
7
8
$ plaintext = "abc " ;
8
9
9
10
$ ciphertext = gmssl_sm4_cbc_encrypt ($ key , $ iv , $ plaintext );
Original file line number Diff line number Diff line change 1
1
<?php
2
2
print ("GMSSL_SM4_KEY_SIZE = " .GMSSL_SM4_KEY_SIZE ."\n" );
3
3
print ("GMSSL_SM4_BLOCK_SIZE = " .GMSSL_SM4_BLOCK_SIZE ."\n" );
4
+ print ("GMSSL_SM4_CTR_IV_SIZE = " .GMSSL_SM4_CTR_IV_SIZE ."\n" );
4
5
5
6
$ key = gmssl_rand_bytes (GMSSL_SM4_KEY_SIZE );
6
- $ iv = gmssl_rand_bytes (GMSSL_SM4_BLOCK_SIZE );
7
+ $ iv = gmssl_rand_bytes (GMSSL_SM4_CTR_IV_SIZE );
7
8
$ plaintext = "abc " ;
8
9
9
10
$ ciphertext = gmssl_sm4_ctr_encrypt ($ key , $ iv , $ plaintext );
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ PHP_MINIT_FUNCTION(gmssl)
48
48
REGISTER_LONG_CONSTANT ("GMSSL_SM3_HMAC_MIN_KEY_SIZE" , 16 , CONST_CS | CONST_PERSISTENT );
49
49
REGISTER_LONG_CONSTANT ("GMSSL_SM4_KEY_SIZE" , SM4_KEY_SIZE , CONST_CS | CONST_PERSISTENT );
50
50
REGISTER_LONG_CONSTANT ("GMSSL_SM4_BLOCK_SIZE" , SM4_BLOCK_SIZE , CONST_CS | CONST_PERSISTENT );
51
+ REGISTER_LONG_CONSTANT ("GMSSL_SM4_CBC_IV_SIZE" , SM4_BLOCK_SIZE , CONST_CS | CONST_PERSISTENT );
52
+ REGISTER_LONG_CONSTANT ("GMSSL_SM4_CTR_IV_SIZE" , SM4_BLOCK_SIZE , CONST_CS | CONST_PERSISTENT );
51
53
REGISTER_LONG_CONSTANT ("GMSSL_SM4_GCM_MIN_IV_SIZE" , SM4_GCM_MIN_IV_SIZE , CONST_CS | CONST_PERSISTENT );
52
54
REGISTER_LONG_CONSTANT ("GMSSL_SM4_GCM_MAX_IV_SIZE" , SM4_GCM_MAX_IV_SIZE , CONST_CS | CONST_PERSISTENT );
53
55
REGISTER_LONG_CONSTANT ("GMSSL_SM4_GCM_DEFAULT_IV_SIZE" , SM4_GCM_IV_DEFAULT_SIZE , CONST_CS | CONST_PERSISTENT );
You can’t perform that action at this time.
0 commit comments