webfunds.ricardian
Class KeyUtil
java.lang.Object
|
+--webfunds.ricardian.KeyUtil
- public final class KeyUtil
- extends java.lang.Object
|
Field Summary |
static java.lang.String |
eoln
Manifest constant for *internal* end of line for OpenPGP. |
|
Method Summary |
static cryptix.openpgp.PGPPublicKey |
checkArmouredPublicKey(java.lang.String armouredKey,
java.lang.String tag,
cryptix.openpgp.PGPPublicKey signer)
Read a Public Key from a string and return the key. |
static cryptix.openpgp.PGPUserID |
findUserId(cryptix.openpgp.PGPPublicKey key,
java.lang.String userIdTag)
Return the first UserId on the key that matches 'userIdTag' or return
null. |
static java.lang.String |
getOpenPGPEndOfLine()
|
static java.lang.String |
getPlatformEndOfLine()
Remember to convert on output. |
static webfunds.ricardian.PGPKey |
keyFromString(java.lang.String keyAsArmouredString)
Load up an armoured key from a string. |
static void |
main(java.lang.String[] argv)
|
static cryptix.openpgp.PGPPublicKey |
publicKeyFromString(java.lang.String s)
|
static java.lang.String |
publicKeyToString(cryptix.openpgp.PGPPublicKey pk)
|
static cryptix.openpgp.PGPSecretKey |
secretKeyFromString(java.lang.String s)
|
static java.lang.String |
secretKeyToString(cryptix.openpgp.PGPSecretKey sk)
|
static cryptix.openpgp.PGPPublicKey |
stripAndVerifyKey(cryptix.openpgp.PGPPublicKey key,
java.lang.String userIdTag,
cryptix.openpgp.PGPPublicKey userIdSigner)
Strip the given key of all superfluous data. |
static boolean |
verifyKey(cryptix.openpgp.PGPPublicKey key,
java.lang.String userIdTag,
cryptix.openpgp.PGPPublicKey userIdSigner)
Verify that the given key is valid. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
eoln
public static final java.lang.String eoln
- Manifest constant for *internal* end of line for OpenPGP.
OpenPGP Signatures (and Ricardian Hashes) are calculated with
this as the end of line (but note that storage occurs with
the platform end of line).
getOpenPGPEndOfLine
public static java.lang.String getOpenPGPEndOfLine()
getPlatformEndOfLine
public static java.lang.String getPlatformEndOfLine()
- Remember to convert on output. This is here more for doco...
publicKeyFromString
public static cryptix.openpgp.PGPPublicKey publicKeyFromString(java.lang.String s)
throws ArmouredKeyException
secretKeyFromString
public static cryptix.openpgp.PGPSecretKey secretKeyFromString(java.lang.String s)
throws ArmouredKeyException
secretKeyToString
public static java.lang.String secretKeyToString(cryptix.openpgp.PGPSecretKey sk)
publicKeyToString
public static java.lang.String publicKeyToString(cryptix.openpgp.PGPPublicKey pk)
keyFromString
public static webfunds.ricardian.PGPKey keyFromString(java.lang.String keyAsArmouredString)
throws ArmouredKeyException
- Load up an armoured key from a string.
No checking other than that intrinsic in de-armouring and
insisting on one and one only key.
checkArmouredPublicKey
public static cryptix.openpgp.PGPPublicKey checkArmouredPublicKey(java.lang.String armouredKey,
java.lang.String tag,
cryptix.openpgp.PGPPublicKey signer)
throws StripKeyException,
ArmouredKeyException
- Read a Public Key from a string and return the key.
It must be signed by the signer, if provided (can be null).
It must be self-signed.
It must have the tag in it somewhere.
Additional sigs are stripped.
stripAndVerifyKey
public static cryptix.openpgp.PGPPublicKey stripAndVerifyKey(cryptix.openpgp.PGPPublicKey key,
java.lang.String userIdTag,
cryptix.openpgp.PGPPublicKey userIdSigner)
throws StripKeyException
- Strip the given key of all superfluous data. The key being returned
will have at most one userId (containing the string userIdTag) which
is both self-signed and (optionally) signed by 'userIdSigner' (if
'userIdSigner' != null).
- Throws:
- java.lang.IllegalArgumentException - If key==null || userIdTag==null.
- StripKeyException - If the requested userId doesn't exist or is not self-signed or
has multiple self-sigs or isn't signed by userIdSigner or has
multiple sigs by userIdSigner (dunno if that's possible) or has
multiple matching userIds. See the number in StripKeyException.
verifyKey
public static boolean verifyKey(cryptix.openpgp.PGPPublicKey key,
java.lang.String userIdTag,
cryptix.openpgp.PGPPublicKey userIdSigner)
- Verify that the given key is valid. Valid is defined as "stripAndVerify
will not throw StripKeyException".
findUserId
public static cryptix.openpgp.PGPUserID findUserId(cryptix.openpgp.PGPPublicKey key,
java.lang.String userIdTag)
throws StripKeyException
- Return the first UserId on the key that matches 'userIdTag' or return
null.
main
public static void main(java.lang.String[] argv)
throws java.lang.Exception