Open itollei opened 2 years ago
是否可以给出完整可编译的Java代码?
老师,我使用的java代码在https://github.com/itollei/gmhelper-master上,您抽空帮我看下,问题出在哪里?非常感谢!
老师,我使用的java代码在https://github.com/itollei/gmhelper-master上,您抽空帮我看下,问题出在哪里?非常感谢!
你好,你搞好了吗?我这边也是 他这个加密出来的密文HEX好奇怪,都是30开头的,应该是用什么格式或者加密过,请问怎么转回来?
关于GMSSL-SM2与其他主流SM2算法加解密不通过的问题,这里有一个案例可以参考
老师,我使用的java代码在https://github.com/itollei/gmhelper-master上,你抽空帮我看下,问题出在哪里?非常感谢!>> 你好,你搞好了吗?我这边也是他这个加密出来的密文HEX好奇怪,都是30开头的,应该是用什么格式或加密过,请问怎么转回来? 30开头应该der编码的。理论上java那边应该是可以直接解这个格式
你好,有使用sm2给数据长度大于255的数据加密吗?非常感谢告知
iOS端加密如下:
void sw_sm2_test(const char p, const char x, const char y, const char plaintext) { format_print(stderr, 0, 0, "sw_sm2_test\n"); SM2_KEY sm2_key; SM2_KEY pub_key;
}
sw_sm2_test sm2_key publicKey x: 4C20C85AED71E9BB6CAA6ED833CB8C4258B02F5BCA9887AD34B710895737BCA4 y: C40774BED2A3C4B878FF5DDF5E20B9C3DCFE287502386A5DB98E7D5AADB9C363 privateKey: 58F36A4F596CDA03AAF33BD6107E7C66022322918F7BDB6305A8E262C7A232FB Ciphertext XCoordinate: 04AD997E3C2214EB4EBF70106F9425B6AEB7AD99809C8ED46A813BFC648C3A37 YCoordinate: 437BF6D8A42C41176357C566CD9F15571C58F4411D19BED8231BDACBCCA796A1 HASH: B475033FDC3CCEE8995443188426C66D4CAB60C47F4494D778E8AFBE9AC3E9F6 CipherText: E8E151252B1C ciphertext: 306E022004AD997E3C2214EB4EBF70106F9425B6AEB7AD99809C8ED46A813BFC648C3A370220437BF6D8A42C41176357C566CD9F15571C58F4411D19BED8231BDACBCCA796A10420B475033FDC3CCEE8995443188426C66D4CAB60C47F4494D778E8AFBE9AC3E9F60406E8E151252B1C outtext: 123456 ok!!!
java端解密报: org.bouncycastle.crypto.InvalidCipherTextException: invalid cipher text at org.bouncycastle.crypto.engines.SM2Engine.decrypt(Unknown Source) at org.bouncycastle.crypto.engines.SM2Engine.processBlock(Unknown Source) at org.zz.gmhelper.SM2Util.decrypt(SM2Util.java:144) at org.zz.gmhelper.test.SM2UtilTest.testEncryptAndDecrypt(SM2UtilTest.java:100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)