IAIK PKCS#11 Provider API Documentation
version 1.6

iaik.pkcs.pkcs11.provider.signatures
Class SignatureUtil

java.lang.Object
  extended by iaik.pkcs.pkcs11.provider.signatures.SignatureUtil

public abstract class SignatureUtil
extends java.lang.Object

This class hosts static utility methods used by two or more classes of this package.


Method Summary
static byte[] ASN1toRS(byte[] sigBytes, int lengthRS)
          This method decodes a X.509 DSA or ECDSA signature and returns the raw r and s values into an byte array.
static byte[] RStoASN1(byte[] rs)
          This method encodes the raw r and s values of a DSA or ECDSA signature into an X.509 signature.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

RStoASN1

public static byte[] RStoASN1(byte[] rs)
                       throws java.security.SignatureException
This method encodes the raw r and s values of a DSA or ECDSA signature into an X.509 signature.

Parameters:
rs - The byte array containing the concatenation of r and s, most significant byte first (no signum bits).
Returns:
byte[] The X.509 encoded DSA or ECDSA signature value.
Throws:
java.security.SignatureException - If encoding the signature value fails.
Preconditions
(rs <> null)
Postconditions
(result <> null)

ASN1toRS

public static byte[] ASN1toRS(byte[] sigBytes,
                              int lengthRS)
                       throws java.security.SignatureException
This method decodes a X.509 DSA or ECDSA signature and returns the raw r and s values into an byte array.

Parameters:
sigBytes - The X.509 encoded DSA or ECDSA signature value.
lengthRS - The length of R and S in bytes, which have both the same length; e.g. 20 bytes. If this is 0, the byte length of r and s will be determined and the longer of both will be taken.
Returns:
The byte array containing the concatenation of r and s, most significant byte first (no signum bits).
Throws:
java.security.SignatureException - If decoding the signature value fails.
Preconditions
(sigBytes <> null) and (lengthRS >= 0)
Postconditions
(result <> null)

IAIK PKCS#11 Provider API Documentation
version 1.6

IAIK JavaSecurity Website http://jce.iaik.tugraz.at/

IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2004, IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved.
version 1.6