I am trying to sign my payload using SHA512withRsa but I am facing issues while verifying the signature can anyone please help me
I want to know what is going wrong in my code is my generating signature code wrong or verifying code wrong
###################################################
Code for signing my payload
keystore = getPrivateKeystore(privateKeyPath, keystorePassowrd. toCharArray));
privateKey = getPrivateKey(privateKeyAlias, privateKeyPassword. toCharArray(), keystore);
MessageDigest digest = MessageDigest. getInstance("SHA512", "BC");
byte[] newDigest = digest. digest (data);
Signature signature = Signature. getInstance( "SHA512withRSA/PSS", "BC");
signature. initSign(privateKey);
signature.update(newDigest);
byte[] sign = signature.sign();
System. out.println(String. valueOf(sign));
return Base64.getEncoder(). encodeToString(sign);
##############################################################
code for verifying signature
public boolean verifySignature (String paload, String signature)throws NoSuchAlgorithmException,
NoSuchProviderException,InvalidAlgorithmParameterException,InvalidKeyException,SignatureException,UnrecoverableKeyException,
KeyStoreEx
Signature ver=Signature.getInstance(“SHA512withRSA/PSS”,”BC”);
ver.initVerify(getPublicKey(publicKeyAlias, keystore));
ver. update(payload.getBytes));
byte[] decode = Base64.getDecoder().decode(signature);
System. out. println(String. valuef(decode));
boolean verify = ver.verify(Base64.getDecoder().decode(signature));
System. out. println (verify);
return verify;
I tried signing my payload with SHA512withRSA algo but I am not able to verify .
I just want to know where I am making mistake is it in my genertaing signature code or verifying code