java.lang.Object
io.helidon.common.crypto.AsymmetricCipher
- All Implemented Interfaces:
CommonCipher
This class provides simple and stateless way to encrypt and decrypt messages using selected asymmetric cipher.
It requires to have a
It requires to have a
PrivateKey
provided for decryption purposes and
a PublicKey
for encryption purposes.-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Deprecated.It is strongly recommended not to use this algorithm as stated here RFC6151 - 2.static final String
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA1 and MGF1.static final String
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-256 and MGF1.static final String
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-384 and MGF1.static final String
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/224 and MGF1.static final String
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/256 and MGF1.static final String
RSA cipher with ECB method using PKCS1 padding. -
Method Summary
Modifier and TypeMethodDescriptionstatic AsymmetricCipher.Builder
builder()
Create a new builder.decrypt
(Base64Value encrypted) Decrypt encrypted message.static Base64Value
decrypt
(String algorithm, String provider, PrivateKey privateKey, Base64Value message) Decrypt the message with the provided private key and selected algorithm.encrypt
(Base64Value message) Encrypt message.static Base64Value
encrypt
(String algorithm, String provider, PublicKey publicKey, Base64Value message) Encrypt the message with the provided public key and selected algorithm.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.common.crypto.CommonCipher
decryptFromString, encryptToString
-
Field Details
-
ALGORITHM_RSA_ECB_OAEP_MD5
Deprecated.It is strongly recommended not to use this algorithm as stated here RFC6151 - 2.RSA cipher with ECB method using optimal asymmetric encryption padding with MD5 and MGF1.
Value is: "RSA/ECB/OAEPWithMD5AndMGF1Padding".- See Also:
-
ALGORITHM_RSA_ECB_OAEP_SHA1
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA1 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA1AndMGF1Padding".- See Also:
-
ALGORITHM_RSA_ECB_OAEP256
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-256 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-256AndMGF1Padding".- See Also:
-
ALGORITHM_RSA_ECB_OAEP384
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-384 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-384AndMGF1Padding".- See Also:
-
ALGORITHM_RSA_ECB_OAEP512_224
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/224 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-512/224AndMGF1Padding".- See Also:
-
ALGORITHM_RSA_ECB_OAEP512_256
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/256 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-512/256AndMGF1Padding".- See Also:
-
ALGORITHM_RSA_ECB_PKCS1
RSA cipher with ECB method using PKCS1 padding.
Value is: "RSA/ECB/PKCS1Padding".- See Also:
-
-
Method Details
-
builder
Create a new builder.- Returns:
- new builder
-
encrypt
public static Base64Value encrypt(String algorithm, String provider, PublicKey publicKey, Base64Value message) Encrypt the message with the provided public key and selected algorithm.- Parameters:
algorithm
- algorithm nameprovider
- algorithm providerpublicKey
- public key used for encryptionmessage
- message to be encrypted- Returns:
- encrypted message
-
decrypt
public static Base64Value decrypt(String algorithm, String provider, PrivateKey privateKey, Base64Value message) Decrypt the message with the provided private key and selected algorithm.- Parameters:
algorithm
- algorithm nameprovider
- algorithm providerprivateKey
- private key used for decryptionmessage
- message to be decrypted- Returns:
- decrypted message
-
encrypt
Description copied from interface:CommonCipher
Encrypt message.- Specified by:
encrypt
in interfaceCommonCipher
- Parameters:
message
- message- Returns:
- encrypted message
-
decrypt
Description copied from interface:CommonCipher
Decrypt encrypted message.- Specified by:
decrypt
in interfaceCommonCipher
- Parameters:
encrypted
- encrypted message- Returns:
- decrypted message
-