We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
近期在做国密密码机对接,发现 sm4 库 gcm 模式下计算出的密文和密码机一致,但是鉴别TAG不同。 系统测试后发现密码机、GmSSL和在线验证结果一致,基本确定本库实现有问题。验证截图如下:
The text was updated successfully, but these errors were encountered:
测试代码如下:
func Demo() { keyHex := "0123456789ABCDEFFEDCBA9876543210" plainHex := "AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAA" ivHex := "00001234567800000000ABCD" aadHex := "FEEDFACEDEADBEEFFEEDFACEDEADBEEFABADDAD2" keyBytes, _ := hex.DecodeString(keyHex) ivBytes, _ := hex.DecodeString(ivHex) aadBytes, _ := hex.DecodeString(aadHex) plainBytes, _ := hex.DecodeString(plainHex) cipherBytes, tagBytes := sm4.GCMEncrypt(keyBytes, ivBytes, plainBytes, aadBytes) log.Println("key in hex:", keyHex) log.Println("plain text in hex:", plainHex) log.Println("iv in hex:", ivHex) log.Println("aad in hex:", aadHex) log.Println("cipher text in hex:", hex.EncodeToString(cipherBytes)) log.Println("tag in hex:", hex.EncodeToString(tagBytes)) }
Sorry, something went wrong.
和#172 #198 类似
No branches or pull requests
近期在做国密密码机对接,发现 sm4 库 gcm 模式下计算出的密文和密码机一致,但是鉴别TAG不同。
系统测试后发现密码机、GmSSL和在线验证结果一致,基本确定本库实现有问题。验证截图如下:
The text was updated successfully, but these errors were encountered: