Comments (5)
这个参考网址打不开
from gmhelper.
更新了下地址,应该是url带着汉字的问题,大佬再试下看。
签名时候,后面有个选项是否计算z值,默认是带的,和用bc库签出来的结果可以互相验签。
当z值不参与运算时,用bc库应该怎么签名和验签呢,请帮忙看下。
from gmhelper.
好,我周末有空看下,平时没时间哈。你要着急的话也可以自己先研究一下。
from gmhelper.
嗯感谢大佬
from gmhelper.
看了下BC的代码(最新的1.70版本),基于BC可能控制不了要不要算Z,它的实现里没有提供控制这个行为的参数。
不过想做的话应该也简单,SM2Signer的代码还是相对牵扯其他东西较少的,可以拷贝出来自己改改应该就可以。
// org.bouncycastle.crypto.signers.SM2Signer
public void init(boolean forSigning, CipherParameters param)
{
CipherParameters baseParam;
byte[] userID;
if (param instanceof ParametersWithID)
{
baseParam = ((ParametersWithID)param).getParameters();
userID = ((ParametersWithID)param).getID();
if (userID.length >= 8192)
{
throw new IllegalArgumentException("SM2 user ID must be less than 2^16 bits long");
}
}
else
{
baseParam = param;
// the default value, string value is "1234567812345678"
userID = Hex.decodeStrict("31323334353637383132333435363738");
}
if (forSigning)
{
if (baseParam instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)baseParam;
ecKey = (ECKeyParameters)rParam.getParameters();
ecParams = ecKey.getParameters();
kCalculator.init(ecParams.getN(), rParam.getRandom());
}
else
{
ecKey = (ECKeyParameters)baseParam;
ecParams = ecKey.getParameters();
kCalculator.init(ecParams.getN(), CryptoServicesRegistrar.getSecureRandom());
}
pubPoint = createBasePointMultiplier().multiply(ecParams.getG(), ((ECPrivateKeyParameters)ecKey).getD()).normalize();
}
else
{
ecKey = (ECKeyParameters)baseParam;
ecParams = ecKey.getParameters();
pubPoint = ((ECPublicKeyParameters)ecKey).getQ();
}
// TODO : 应该在这里加个if判断决定要不要执行后面的两行代码即可
z = getZ(userID);
digest.update(z, 0, z.length);
}
from gmhelper.
Related Issues (20)
- SM2Util.encodeSM2CipherToDER 有概率有报java.lang.IllegalArgumentException: malformed integer错误 HOT 1
- sm2 加解密算法中 s及中文会丢失 HOT 2
- Android上的问题 HOT 2
- SM2签名长度的问题
- 关于SM协同签名 HOT 1
- 嗨,老板。 HOT 1
- 请教个sm4问题。 HOT 3
- 请问有.net版本吗 HOT 4
- 加密后的数据固定04开头,这个要怎么去掉
- 报错信息 HOT 1
- is there a javascript lib to match with the bouncycastle & gmhelper ? HOT 1
- 前端用sm-crypto生成的sm2签名,用后台用这个封装后的验签方法验不过,后台生成的签名前端同样验不过是什么问题啊 HOT 2
- 大佬能否封装jar静态类 HOT 1
- Function testPfxSign error in Sm2PfMakerTest.java
- Function testPfxSign error in Sm2PfMakerTest.java HOT 3
- SM4加密,第一次特别慢,有办法解决吗? HOT 7
- 关于国密算法SM2加密问题,使用老版本的bcprov包改造加密实现,渠道接入无法解密,求解答 HOT 2
- 有没有计划发布到maven中心仓库? HOT 1
- 这个与gmssl签名能互通吗?· HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gmhelper.