IOS armv7版sm3 sm2加解密问题
老师,你好! 我用最新的GmSSL-v1编译出了ios armv7、arm64和win32版libcrypto.a,但真机测试中却发现一个奇怪问题: 1)armv7版在真机中自己加密,然后自己解密是可以通过的,但是如果用其他平台加密,在ios armv7真机上解密会报错: EVP_PKEY_decrypt fail:error:3406B06A:SM2 routines:SM2_do_decrypt:error 或 SM2_decrypt_with_recommended fail:error:3406B06A:SM2 routines:SM2_do_decrypt:error
反过来,在armv7上加密,其他平台解密也会报错。
2)另外 armv7上做sm3摘要计算也和其他平台结果不同: char testdata[] = "1234567890qwettyuiooygfdvksgnxxfetrjlajfrgvvmsiakg023456789abcdefg"; armv7上Sm3Digest得出结果: 0494E94C816AF7335AEE732415D42CBA508041079BF6B22A7D9FFFD188A98AF4 其他平台Sm3Digest为: 2779E21B44AE44C6F2AEA8F2642D2F478FFC01C8F6425D652C89B2287A28AAA0
3)相同代码在ios arm64真机平台则一切正常,可与其他平台互通。
同学,你怎么编译的?我的arm64上可以正常运行,armv7加载库就crash了!
iOS ARM7对应的具体设备型号是什么?
@guanzhi A1526 iPhone5c 对输入"abc" 得到的结果为 "85f1d9d5 624d8219 7414473e a25ec64d 15baec95 cd36bfac 229fb88f daa0a352"
@guanzhi 应该是sm3中ROTATELEFT宏,当移位超过32时出错了。
@zhaoruixbj 请教一下怎么编译的,我用最新的gmssl库参考这篇文章(http://blog.cocoachina.com/article/38141)编译报错:
crypto/aes/aes_core.c:632:5: error: conflicting types for 'AES_set_encrypt_key'
int AES_set_encrypt_key(const unsigned char *userKey, int bits,
^
include/openssl/aes.h:43:5: note: previous declaration is here
int AES_set_encrypt_key(const unsigned char *userKey, const unsigned int bits,
^
1 error generated.
@lixiayi @bossbei 我是用的网上编译ios版openssl的脚本直接编译的,参考: https://github.com/hvge/openssl-libs/blob/master/build-ios.sh
@guanzhi iphone 5s以前机型都是32位的,我们测试用的是iphone 5c和ipod touch
@zhaoruixbj 谢谢回复,这个是openssl的编译脚本,编译gmssl的要怎么修改呢
Marked as stale issue. Will be closed later if no activity for a while.