java.lang.Object
org.refcodes.forwardsecrecy.ForwardSecrecyUtility
The Class ForwardSecrecyUtility.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Default way on how to create a cipher.static String
Default way on how to create a cipher UID.static String
Default way on how to create a message which is to be signed in order to identify the owner of a public key.static boolean
hasEncryptionPattern
(String aText) Returns true in case the given text provided the characteristics of an encrypted text as of the cipher and cipher UID pattern. ------------------------------------------------------------------------- CAUTION: A plain text may have the same characteristics, an encrypted text must have these characteristics!static PrivateKey
readPrivateKey
(File aFile, String aPassword) static PublicKey
readPublicKey
(File aFile) static String
toCipherUidPrefix
(String aCipherUidWithEncryptedText) Expects a text with a prefixed cipher UID.static String
toEncryptedTextBody
(String aCipherUidWithEncryptedText) Expects a text with a prefixed cipher UID.
-
Field Details
-
CIPHER_LENGTH
public static final int CIPHER_LENGTH- See Also:
-
MESSAGE_LENGTH
public static final int MESSAGE_LENGTH- See Also:
-
CIPHER_UID_TIMESTAMP_LENGTH
public static final int CIPHER_UID_TIMESTAMP_LENGTH- See Also:
-
CIPHER_UID_LENGTH
public static final int CIPHER_UID_LENGTH- See Also:
-
-
Method Details
-
hasEncryptionPattern
Returns true in case the given text provided the characteristics of an encrypted text as of the cipher and cipher UID pattern. ------------------------------------------------------------------------- CAUTION: A plain text may have the same characteristics, an encrypted text must have these characteristics! -------------------------------------------------------------------------- Parameters:
aText
- The text to test whether it is encrypted.- Returns:
- True in case the given text has the characteristics of an encrypted text
-
toCipherUidPrefix
Expects a text with a prefixed cipher UID. Extracts the cipher UID with which the given text was encrypted.- Parameters:
aCipherUidWithEncryptedText
- The encrypted text with the prefixed cipher UID- Returns:
- The cipher UID or null if none cipher UID was found
-
toEncryptedTextBody
Expects a text with a prefixed cipher UID. Extracts the encrypted Text without the prefixed cipher UID.- Parameters:
aCipherUidWithEncryptedText
- The encrypted text with the prefixed cipher UID- Returns:
- The encrypted text portion or null if none cipher UID was found (then we have an invalid format of the provided text)
-
createCipherUid
Default way on how to create a cipher UID. In case the default way generated bad cipher UIDs, the default way's implementation is changed making it good again and all system using the default way. The timestamp is prepended so that regarding on the timestamp, encrypted texts can be easily selected, e.g. texts being encrypted with a cipher older than a given timestamp.- Returns:
- A cipher UID created the default way.
-
createCipher
Default way on how to create a cipher. In case the default way generated bad ciphers, the default way's implementation is changed making it secure again and all system using the default way.- Returns:
- A cipher created the default way.
-
createMessage
Default way on how to create a message which is to be signed in order to identify the owner of a public key.- Returns:
- A message created the default way.
-
readPrivateKey
public static PrivateKey readPrivateKey(File aFile, String aPassword) throws InvalidKeySpecException, NoSuchAlgorithmException, IOException -
readPublicKey
public static PublicKey readPublicKey(File aFile) throws InvalidKeySpecException, NoSuchAlgorithmException, IOException
-