@Test public void pssDER() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, DataLengthException, CryptoException, InvalidKeyException, SignatureException, InvalidKeySpecException, IOException{ KeyPair keyPair = KeyCodec.getRSAKeyPair(); KeyPair keyPair2 = KeyCodec.getRSAKeyPair(); PrivateKey privKey = keyPair.getPrivate(); byte[] encodedPrivKey = privKey.getEncoded(); logger.info("priv=" + Base64.encodeBase64URLSafeString(encodedPrivKey)); PublicKey pubKey = keyPair.getPublic(); byte[] encodedPubKey = pubKey.getEncoded(); logger.info("pub=" + Base64.encodeBase64URLSafeString(encodedPubKey)); logger.info("pub format=" + pubKey.getFormat()); logger.info("pub alg=" + pubKey.getAlgorithm()); byte[] slt = Hex.decode("dee959c7e06411361420ff80185ed57f3e6776af"); byte[] signed = RSA.signPSS(privKey, slt); assertTrue(signed.length>0); RSA rsa = new RSA(); Assert.assertTrue(rsa.verifyPSS(pubKey, slt, signed)); byte[] slt2 = Hex.decode("dee959c7e06411361420ff80185ed57f3e6776aa"); byte[] signed2 = RSA.signPSS(keyPair2.getPrivate(), slt2); Assert.assertFalse(rsa.verifyPSS(pubKey, slt2, signed2)); Assert.assertFalse(rsa.verifyPSS(keyPair2.getPublic(), slt, signed)); }
public static KeyPair getRSAKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { KeyPairGenerator g = KeyPairGenerator.getInstance("RSA", "BC"); g.initialize(2048); return g.generateKeyPair(); }
KeyCodec { public static KeyPair getRSAKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { KeyPairGenerator g = KeyPairGenerator.getInstance("RSA", "BC"); g.initialize(2048); return g.generateKeyPair(); } }
KeyCodec { public static KeyPair getRSAKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { KeyPairGenerator g = KeyPairGenerator.getInstance("RSA", "BC"); g.initialize(2048); return g.generateKeyPair(); }  }
KeyCodec { public static KeyPair getRSAKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { KeyPairGenerator g = KeyPairGenerator.getInstance("RSA", "BC"); g.initialize(2048); return g.generateKeyPair(); }  static KeyPair getKeyPair(); static KeyPair getRSAKeyPair(); static RSAKeyParameters generatePrivateKeyParameter(RSAPrivateKey key); static byte[] getKeyAsRawBytes(String base64EncodedPubKey); static byte[] getKeyAsRawBytes(BCECPublicKey pub); @SuppressWarnings("deprecation") static byte[] getKeyAsRawBytes(
			org.bouncycastle.jce.interfaces.ECPublicKey pub); static byte[] asUnsignedByteArray(BigInteger value); static PublicKey getPubKey(byte[] bytes); static PrivateKey getPrivKey(byte[] bytes); static KeyPair generate(); static PublicKey getPubKeyFromCurve(byte[] pubKey, String curveName); static PublicKey getRSAPublicKey(byte[] encodedPubKey); static PrivateKey getPrivKeyFromCurve(byte[] privKey,
			String curveName); }
KeyCodec { public static KeyPair getRSAKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { KeyPairGenerator g = KeyPairGenerator.getInstance("RSA", "BC"); g.initialize(2048); return g.generateKeyPair(); }  static KeyPair getKeyPair(); static KeyPair getRSAKeyPair(); static RSAKeyParameters generatePrivateKeyParameter(RSAPrivateKey key); static byte[] getKeyAsRawBytes(String base64EncodedPubKey); static byte[] getKeyAsRawBytes(BCECPublicKey pub); @SuppressWarnings("deprecation") static byte[] getKeyAsRawBytes(
			org.bouncycastle.jce.interfaces.ECPublicKey pub); static byte[] asUnsignedByteArray(BigInteger value); static PublicKey getPubKey(byte[] bytes); static PrivateKey getPrivKey(byte[] bytes); static KeyPair generate(); static PublicKey getPubKeyFromCurve(byte[] pubKey, String curveName); static PublicKey getRSAPublicKey(byte[] encodedPubKey); static PrivateKey getPrivKeyFromCurve(byte[] privKey,
			String curveName);  }