XCMS Toolkit

com.cms.crypto
Class PublicKeyAdapter

java.lang.Object
  extended by com.cms.crypto.PublicKeyAdapter
All Implemented Interfaces:
java.io.Serializable, java.security.Key, java.security.PublicKey

public class PublicKeyAdapter
extends java.lang.Object
implements java.security.PublicKey

Implements the PublicKey public interface and uses the Adapter design pattern to provide a meachanism to manipulate Java class PublicKey.

Version:
1.00 - 2006/02/26
Author:
support@phillipgriffin.com
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface java.security.PublicKey
serialVersionUID
 
Constructor Summary
PublicKeyAdapter(java.security.PublicKey key)
          Constructor for PublicKeyAdapter with public key parameter.
 
Method Summary
 boolean equals(java.lang.Object object)
          Returns boolean true or false indicating whether or not two public keys are the same.
 java.lang.String getAlgorithm()
          Returns a public key algorithm.
 byte[] getEncoded()
          Returns an encoded public key.
 java.lang.String getFormat()
          Returns a public key format.
 byte[] getMessageDigest()
          Gets a SHA-1 message digest of a value of ASN.1 type SubjectPublicKeyInfo for an ECDSA public key.
 byte[] getMessageDigest(DigestAlgorithmIdentifier algorithmId)
          Gets the message digest of a value of ASN.1 type SubjectPublicKeyInfo for an ECDSA public key using the hash algorithm specified by the provided digest algorithm identifier.
 byte[] getSubjectPublicKeyInfo()
          Gets the public key bits from a value of ASN.1 type SubjectPublicKeyInfo.
 int hashCode()
          Returns the message digest (hash) of a public key (SubjectPublicKeyInfo).
 java.lang.String toString()
          Returns a braces delimted string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PublicKeyAdapter

public PublicKeyAdapter(java.security.PublicKey key)
Constructor for PublicKeyAdapter with public key parameter.

Parameters:
key - the public key component of a public-private key pair
Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Returns a public key algorithm.

Specified by:
getAlgorithm in interface java.security.Key

getFormat

public java.lang.String getFormat()
Returns a public key format.

Specified by:
getFormat in interface java.security.Key

getEncoded

public byte[] getEncoded()
Returns an encoded public key.

Specified by:
getEncoded in interface java.security.Key

equals

public boolean equals(java.lang.Object object)
Returns boolean true or false indicating whether or not two public keys are the same.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns the message digest (hash) of a public key (SubjectPublicKeyInfo).

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a braces delimted string.

Overrides:
toString in class java.lang.Object

getSubjectPublicKeyInfo

public byte[] getSubjectPublicKeyInfo()
                               throws DecodingException,
                                      java.io.IOException
Gets the public key bits from a value of ASN.1 type SubjectPublicKeyInfo.

Shades of Brian Korver (aka Luke Bytewalker)! We're byte walking the following ASN.1 value to get the encoded ECPublicKey bits.

For ECMQV, the OriginatorPublicKey.algorithm.parameters field always contains an OpenType that contains an OBJECT IDENTIFIER that indicates a named elliptic curve.

We are assuming here that all tags are one byte in length.

 SubjectPublicKeyInfo ::= SEQUENCE {
    algorithm  PublicKeyAlgorithmIdentifier,
    publicKey  BIT STRING
 }
 

Returns:
the public key bits
Throws:
DecodingException
java.io.IOException

getMessageDigest

public byte[] getMessageDigest()
                        throws DecodingException,
                               java.io.IOException,
                               java.security.NoSuchAlgorithmException
Gets a SHA-1 message digest of a value of ASN.1 type SubjectPublicKeyInfo for an ECDSA public key.

Returns:
a message digest (SHA-1 hash)
Throws:
DecodingException
java.io.IOException
java.security.NoSuchAlgorithmException

getMessageDigest

public byte[] getMessageDigest(DigestAlgorithmIdentifier algorithmId)
                        throws DecodingException,
                               java.io.IOException,
                               java.security.NoSuchAlgorithmException
Gets the message digest of a value of ASN.1 type SubjectPublicKeyInfo for an ECDSA public key using the hash algorithm specified by the provided digest algorithm identifier.

Parameters:
algorithmId - a message digest algorithm identifier
Returns:
a message digest (hash)
Throws:
DecodingException
java.io.IOException
java.security.NoSuchAlgorithmException

XCMS Toolkit


Copyright © 2005-2006 GRIFFIN Consulting. All Rights Reserved.