Class RSABlindSignatureClient
- java.lang.Object
-
- org.bouncycastle.crypto.signers.RSABlindSignatureClient
-
public class RSABlindSignatureClient extends java.lang.ObjectClient side of the RSA Blind Signature Scheme with Appendix (RSABSSA) defined in RFC 9474. A singleblind(byte[])call performs bothPrepare(sec. 4.1) andBlind(sec. 4.2);finalize(Blinded, byte[])performsFinalize(sec. 4.4). TheBlindSignserver step lives inRSABlindSignatureServerand the variant choices inRSABlindSignatureParameters.The client side is therefore two calls —
blindthenfinalize— with the server'sBlindSignin between:
TheRSABlindSignatureClient client = new RSABlindSignatureClient( RSABlindSignatureParameters.RSABSSA_SHA384_PSS_RANDOMIZED, publicKey); RSABlindSignatureClient.Blinded blinded = client.blind(msg); // send blinded.getBlindedMessage() to the server; receive blind_sig byte[] sig = client.finalize(blinded, blindSig); // (blinded.getPreparedMessage(), sig) is the RSASSA-PSS pair verifiers checkSecureRandomused for the prepare prefix, the EMSA-PSS salt, and the blinding factor is supplied at construction; the(parameters, publicKey)convenience constructor uses theCryptoServicesRegistrardefault.Blindis expressed on the existing BC RSA blinding toolkit —RSABlindingFactorGenerator,RSABlindingParametersandPSSSignerdriven by anRSABlindingEngine— the same compositionPSSBlindTestuses for Chaum RSA-PSS blind signing.Each request's state is carried by the returned
RSABlindSignatureClient.Blinded(the blinded message, the prepared message, and the secret unblinding value), so a single instance is reusable across requests.For randomised variants the resulting signature is over a prepared message that prepends a fresh 32-byte prefix to
msg(RFC 9474 sec. 4.1); that prepared message —RSABlindSignatureClient.Blinded.getPreparedMessage()— is what downstream verifiers check the signature against, not the originalmsg.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRSABlindSignatureClient.BlindedOutput ofblind(byte[]).
-
Constructor Summary
Constructors Constructor Description RSABlindSignatureClient(RSABlindSignatureParameters parameters, RSAKeyParameters publicKey)Equivalent toRSABlindSignatureClient(RSABlindSignatureParameters, RSAKeyParameters, SecureRandom)with aSecureRandomobtained fromCryptoServicesRegistrar.RSABlindSignatureClient(RSABlindSignatureParameters parameters, RSAKeyParameters publicKey, java.security.SecureRandom random)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RSABlindSignatureClient.Blindedblind(byte[] msg)RFC 9474Prepare(sec. 4.1) followed byBlind(sec. 4.2): preparemsg(prepend a fresh 32-byte prefix for randomised variants, identity otherwise), EMSA-PSS encode it, draw an invertible blinding factorr, and blind the encoding toz = encoded_msg * r^e mod n.byte[]finalize(RSABlindSignatureClient.Blinded blinded, byte[] blindSig)RFC 9474Finalize(sec. 4.4): unblind the server's signature for the suppliedRSABlindSignatureClient.Blindedrequest and verify it as a standard RSASSA-PSS signature over the prepared message.
-
-
-
Constructor Detail
-
RSABlindSignatureClient
public RSABlindSignatureClient(RSABlindSignatureParameters parameters, RSAKeyParameters publicKey)
Equivalent toRSABlindSignatureClient(RSABlindSignatureParameters, RSAKeyParameters, SecureRandom)with aSecureRandomobtained fromCryptoServicesRegistrar.- Parameters:
parameters- the RFC 9474 sec. 5 variant.publicKey- the server's RSA public key.
-
RSABlindSignatureClient
public RSABlindSignatureClient(RSABlindSignatureParameters parameters, RSAKeyParameters publicKey, java.security.SecureRandom random)
- Parameters:
parameters- the RFC 9474 sec. 5 variant.publicKey- the server's RSA public key.random- source of randomness for the prepare prefix (randomised variants), the EMSA-PSS salt, and the blinding factor; must not benull— useRSABlindSignatureClient(RSABlindSignatureParameters, RSAKeyParameters)for theCryptoServicesRegistrardefault.
-
-
Method Detail
-
blind
public RSABlindSignatureClient.Blinded blind(byte[] msg) throws CryptoException
RFC 9474Prepare(sec. 4.1) followed byBlind(sec. 4.2): preparemsg(prepend a fresh 32-byte prefix for randomised variants, identity otherwise), EMSA-PSS encode it, draw an invertible blinding factorr, and blind the encoding toz = encoded_msg * r^e mod n. The returnedRSABlindSignatureClient.Blindedcarries the prepared message, theblinded_msgto send to the server, and the secret unblinding value forfinalize(Blinded, byte[]).- Parameters:
msg- the application message to be signed.- Throws:
CryptoException- if EMSA-PSS encoding fails (e.g. the modulus is too small for the variant's hash/salt lengths) or the encoded message is not coprime with the modulus.
-
finalize
public byte[] finalize(RSABlindSignatureClient.Blinded blinded, byte[] blindSig) throws CryptoException
RFC 9474Finalize(sec. 4.4): unblind the server's signature for the suppliedRSABlindSignatureClient.Blindedrequest and verify it as a standard RSASSA-PSS signature over the prepared message.The method name follows the RFC 9474 sec. 4.4
Finalizestep; it is an overload ofObject.finalize()(distinct signature), not an override.- Parameters:
blinded- the value returned byblind(byte[])for this request.blindSig- theblind_sigreturned by the server.- Returns:
- the unblinded RSASSA-PSS signature; it verifies against
blinded.getPreparedMessage(). - Throws:
CryptoException- ifblindSighas the wrong length or the unblinded signature fails RSASSA-PSS verification.
-
-