public static boolean verify(Curves curve, ECPublicKey key, byte[] signature, byte[]... data) { return verify(curve, key, signature, 0, signature.length, data); }
public boolean verify(byte[] signature, int sigoffset, int siglen, byte[]... data) { return verify(curve, getPublicKey(), signature, sigoffset, siglen, data); }
public boolean verify(byte[] signature, byte[]... data) { return verify(curve, getPublicKey(), signature, data); }
private String ecdsaSignRef(String mySignedReference) throws NodeInitException { if(logMINOR) Logger.minor(this, "Signing reference:\n"+mySignedReference); try{ byte[] ref = mySignedReference.getBytes("UTF-8"); // We don't need a padded signature here byte[] sig = ecdsaP256.sign(ref); if(logMINOR && !ECDSA.verify(Curves.P256, getECDSAP256Pubkey(), sig, ref)) throw new NodeInitException(NodeInitException.EXIT_EXCEPTION_TO_DEBUG, mySignedReference); return Base64.encode(sig); } catch(UnsupportedEncodingException e){ //duh ? Logger.error(this, "Error while signing the node identity!" + e, e); System.err.println("Error while signing the node identity!"+e); e.printStackTrace(); throw new NodeInitException(NodeInitException.EXIT_CRAPPY_JVM, "Impossible: JVM doesn't support UTF-8"); } }
System.out.println("ToSign : "+toSign + " ("+toHex(signedBytes)+")"); System.out.println("Signature: "+ toHex(sig)); System.out.println("Verify? : "+ecdsa.verify(sig, signedBytes)); ECDSA ecdsa2 = new ECDSA(sfs.getSubset(curve.name()), curve); System.out.println(ecdsa2.getPublicKey()); System.out.println("Verify? : "+ecdsa2.verify(sig, signedBytes));
verifyECDSA = ECDSA.verify(Curves.P256, peerECDSAPubKey, Base64.decode(signatureP256), toVerifyECDSA);
if(!ECDSA.verify(Curves.P256, pn.peerECDSAPubKey, sig, hisExponential)) { if(pn.peerECDSAPubKeyHash == null) {
bufferOffset += dataLen; System.arraycopy(pn.jfkMyRef, 0, locallyGeneratedText, bufferOffset, pn.jfkMyRef.length); if(!ECDSA.verify(Curves.P256, pn.peerECDSAPubKey, sig, locallyGeneratedText)) { Logger.error(this, "The ECDSA signature verification has failed!! JFK(4) - "+pn.getPeer()+" length "+locallyGeneratedText.length+" hisRef "+hisRef.length+" hash "+Fields.hashCode(hisRef)+" myRef "+pn.jfkMyRef.length+" hash "+Fields.hashCode(pn.jfkMyRef)+" boot ID "+bootID); return true;
if(!ECDSA.verify(Curves.P256, pn.peerECDSAPubKey, sig, toVerify)) { Logger.error(this, "The ECDSA signature verification has failed!! JFK(3) - "+pn.getPeer()); return;