我正在使用jose.4.j库通过RSA-OAEP-256算法和A256CBC-HS512加密方法使用JWE对密码进行加密。有一个用于加密的公共密钥是证书。
JsonWebEncryption jwe = new JsonWebEncryption();
jwe.setPayload("Hello World!");
jwe.setAlgorithmHeaderValue(KeyManagementAlgorithmIdentifiers.RSA_OAEP_256);
jwe.setEncryptionMethodHeaderParameter(ContentEncryptionAlgorithmIdentifiers.AES_256_CBC_HMAC_SHA_512);
FileInputStream fin = new FileInputStream("C:/xxx.cer");
CertificateFactory f = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate)f.generateCertificate(fin);
RSAPublicKey pk = (RSAPublicKey) certificate.getPublicKey();
jwe.setKey(pk);
//jwe.setCertificateChainHeaderValue(certificate);
String serializedJwe = jwe.getCompactSerialization();
System.out.println("Serialized Encrypted JWE: " + serializedJwe);
虽然我收到以下错误
RSA-OAEP-256 is an unknown, unsupported or unavailable alg algorithm (not one of [RSA1_5, RSA-OAEP, dir, A128KW, A192KW, A256KW, ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW, PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW]).