ECDSA安全编码组件 @author SeanDragon
| 34 | * @author SeanDragon |
| 35 | */ |
| 36 | public final class ToolECDSA { |
| 37 | private ToolECDSA() { |
| 38 | throw new UnsupportedOperationException("我是工具类,别初始化我。。。"); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * 数字签名 密钥算法 |
| 43 | */ |
| 44 | private static final String KEY_ALGORITHM = "ECDSA"; |
| 45 | |
| 46 | /** |
| 47 | * 数字签名 签名/验证算法 |
| 48 | * <p> |
| 49 | * Bouncy Castle支持以下7种算法 |
| 50 | * NONEwithECDSA |
| 51 | * RIPEMD160withECDSA |
| 52 | * SHA1withECDSA |
| 53 | * SHA224withECDSA |
| 54 | * SHA256withECDSA |
| 55 | * SHA384withECDSA |
| 56 | * SHA512withECDSA |
| 57 | */ |
| 58 | private static final String SIGNATURE_ALGORITHM = "SHA512withECDSA"; |
| 59 | |
| 60 | /** |
| 61 | * 公钥 |
| 62 | */ |
| 63 | private static final String PUBLIC_KEY = "ECDSAPublicKey"; |
| 64 | |
| 65 | /** |
| 66 | * 私钥 |
| 67 | */ |
| 68 | private static final String PRIVATE_KEY = "ECDSAPrivateKey"; |
| 69 | |
| 70 | /** |
| 71 | * 初始化密钥 |
| 72 | * |
| 73 | * @return Map 密钥Map |
| 74 | * |
| 75 | * @throws Exception |
| 76 | */ |
| 77 | public static Map<String, Object> initKey() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { |
| 78 | // 加入BouncyCastleProvider支持 |
| 79 | Security.addProvider(new BouncyCastleProvider()); |
| 80 | |
| 81 | BigInteger p = new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"); |
| 82 | |
| 83 | ECFieldFp ecFieldFp = new ECFieldFp(p); |
| 84 | |
| 85 | BigInteger a = new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16); |
| 86 | |
| 87 | BigInteger b = new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16); |
| 88 | |
| 89 | EllipticCurve ellipticCurve = new EllipticCurve(ecFieldFp, a, b); |
| 90 | |
| 91 | BigInteger x = new BigInteger("110282003749548856476348533541186204577905061504881242240149511594420911"); |
| 92 | |
| 93 | BigInteger y = new BigInteger("869078407435509378747351873793058868500210384946040694651368759217025454"); |
nothing calls this directly
no outgoing calls
no test coverage detected