|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--spki.BaseObj
|
+--spki.PublicKey
This class represents a public signature key object. It provides everything a user needs to employ the key for checking signatures.
A collision-free hash of the SList canonical representation of an instance of this object yields a SPKI global identifier (and so does the SList itself, but a hash is much smaller). This can be done by calling the getKeyHash() method. An alternative is to use just the Base64-encoded hash value returned by the getKeyId() method.
Formal definition:
<alg-id>:: <byte-string> | <uri> ;
<pub-sig-alg-id>:: <alg-id> ;
<pub-key>:: "(" "public-key" "(" <pub-sig-alg-id> <s-expr>+ ")" ")" ;
The RSA-keys S-Expression must contain the following s-expressions tokens: n and e, of the form (<token> <keydata>).
It also interfaces with the [I]JCA ([International] Java Cryptography Architecture) where possible, which means that we can use crypto-packages such as Systemic's Cryptix, which we do. This has some consequences for the signatures generated.
NOTE: For now, only String is supported for the algorithm-id. NOTE: only rsa-pkcs1-sha1 is supported for now.
TODO: support using URI as the algorithm-id?
Signature| Field Summary | |
private static String |
__ME
This class's full name. |
private String |
cachedKeyId
Cached key-id. |
private PublicKey |
jca_key
The key, used by JCA. |
private Hash |
keyhash
Hash of the public key. |
static String |
SEXP_NAME
This class S-Expression type name, used by toSExpression() and other methods. |
private Signature |
sig
Signature object used for verification. |
private String |
sig_alg_id
Signature algorithm-id. |
private String |
signature_provider
Signature Provider ID. |
| Fields inherited from class spki.BaseObj |
__ME,
cache_sexp,
cached_sexp,
DEFAULT_HASH_ALG,
locked,
SEXP_NAME |
| Constructor Summary | |
private |
PublicKey()
Don't use me! |
|
PublicKey(PublicKey pk)
Create an immutable PublicKey from a java.security.PublicKey object. |
|
PublicKey(SExpression sexp)
Create an immutable PublicKey object from an S-Expression. |
| Method Summary | |
boolean |
equals(Principal that)
Compare this object with another principal. |
String |
getAlgId()
Get the SPKI encryption/signature algorithm id associated with the key. |
Key |
getJCAKey()
Get a key object usable by [I]JCA packages. |
Hash |
getKeyHash()
Get a Hash representing this key using the default hash algorithm. |
Hash |
getKeyHash(String hashAlg)
Get a Hash representing this key using the specified hashing algorithm. |
String |
getKeyId()
Get the key-id of this key. |
Principal |
toHashPrincipal()
Convert this principal into a hash representation. |
SExpression |
toSExpression()
Build an SExpression representing this object. |
boolean |
verify(byte[] input,
byte[] sig_params)
Verify a given input against a given signature using this public key. |
boolean |
verify(Hash hash,
byte[] sig_params)
Verify a given Hash object against a given signature value with this public key. |
boolean |
verify(Signature sig)
Verify a given Signature using this public key. |
| Methods inherited from class spki.BaseObj |
disableSExpressionCaching,
enableSExpressionCaching,
extractHashAlgId,
getCachedSExpression,
isLocked,
isSListOfType,
lock,
providerToSPKI,
setCachedSExpression,
spkiToProvider,
toString |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static final String __ME
public static final String SEXP_NAME
private PublicKey jca_key
private String sig_alg_id
private String signature_provider
private Signature sig
private Hash keyhash
private String cachedKeyId
getKeyId()| Constructor Detail |
private PublicKey()
PublicKey(SExpression),
PublicKey(java.security.PublicKey)
public PublicKey(SExpression sexp)
throws SPKIException,
ParseException
BaseObj.BaseObj(SExpression)
public PublicKey(PublicKey pk)
throws SPKIException
pk - Object implementing the java.security.PublicKey interface.| Method Detail |
public SExpression toSExpression()
throws SPKIException
public String getAlgId()
public Key getJCAKey()
public Hash getKeyHash()
throws SPKIException
public Hash getKeyHash(String hashAlg)
throws SPKIException
hashAlg - hashing algorithm-id (currently "sha1" or "md5").Key.getKeyHash(String)
public String getKeyId()
throws SPKIException
public boolean equals(Principal that)
that - a principal to compare with.
public Principal toHashPrincipal()
throws SPKIException
public boolean verify(Hash hash,
byte[] sig_params)
throws SPKIException
hash - the Hash object to be verified.sig_params - the signature value to verify against the hash.
public boolean verify(byte[] input,
byte[] sig_params)
throws SPKIException
input - the data byte-array to be verified.sig_params - the signature value to verify against the input.verify(Hash,byte[])
public boolean verify(Signature sig)
throws SPKIException
sig - the Signature object to be verified.verify(Hash,byte[])
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||