|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.squawk.security.verifier.SignatureVerifier
public class SignatureVerifier
| Field Summary | |
|---|---|
static int |
BUFFER_SIZE
The numbe of bytes read from flash memory and passed to the signature verification per loop. |
static boolean |
DEBUG
DEBUG is used for enabling and disabling debug code, usually to write debug messages which are defined in the form: if (SignatureVerifier.DEBUG) { |
static int |
MAXIMUM_HEADER_SIZE
The maximum size the header of a suite can have to be compatible with SignatureVerifier. |
| Constructor Summary | |
|---|---|
SignatureVerifier()
Creates a new instance of SignatureVerifier |
|
| Method Summary | |
|---|---|
protected static void |
ensureInitialized()
|
static boolean |
getSuiteVerifiedFlag(int suiteAddress)
|
static void |
initialize(byte[] publicKeyBytes,
int offset,
int length)
|
static boolean |
isVerifiedSuite(String uri)
|
static void |
verify(byte[] buffer,
byte[] signature)
|
static void |
verify(byte[] buffer,
int bufferOffset,
int bufferLength,
byte[] signature,
int signatureOffset,
int signatureLength)
Verifies a buffer TODO: javadoc TODO: support both native and normal verification. |
static void |
verifySuite(InputStream suiteIn)
Verifies a suite in flash memory. |
static void |
verifySuite(InputStream suiteIn,
boolean useNativeSHA)
Verifies a suite in flash memory using either the java Signature or a native read from flash and sha1 code. |
static void |
verifySuite(String uri)
Verifies a suite in flash memory. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean DEBUG
public static final int MAXIMUM_HEADER_SIZE
public static final int BUFFER_SIZE
| Constructor Detail |
|---|
public SignatureVerifier()
| Method Detail |
|---|
public static void initialize(byte[] publicKeyBytes,
int offset,
int length)
throws SignatureVerifierException
SignatureVerifierException
public static void verify(byte[] buffer,
byte[] signature)
throws SignatureVerifierException,
IOException
SignatureVerifierException
IOException
public static void verify(byte[] buffer,
int bufferOffset,
int bufferLength,
byte[] signature,
int signatureOffset,
int signatureLength)
throws SignatureVerifierException,
IOException
SignatureVerifierException
IOException
public static void verifySuite(String uri)
throws SignatureVerifierException,
IOException
uri - A uri pointing to a suite in flash memory. (flash://[.lib])ignoreSuiteVerifiedFlag - If true, verifySuite verifies the suite
even if SuiteVerifiedFlag in the suite is true. It neither updates
the flag after verification.
SignatureVerifierException
IOException
public static void verifySuite(InputStream suiteIn)
throws SignatureVerifierException,
IOException
suiteIn - An input stream which allows retrieving a suite. This usually
is a FlashInputStream pointing to a suite in the flash memory.
SignatureVerifierException
IOException
public static void verifySuite(InputStream suiteIn,
boolean useNativeSHA)
throws SignatureVerifierException,
IOException
Remark: The suite header must be shorter than MAXIMUM_HEADER_SIZE bytes. This is only guarenteed in the case that the suite is in flash memory on a Spot, because it is ensured in com/syn/squawk/suiteconverter/Suite.java by replacing the parentURL with a url of the form flash://
.lib. If the suite is a suite file on the desktop, this is not garanteed, because the parent URL can have any length. Furthermore verifySuite expects that the first integer after the object memory in the suite is the hash. This is only the case for suite converted for flashmemory, thus it won't work for other suites.
suiteIn - An input stream which allows retrieving a suite. This usually
is a FlashInputStream pointing to a suite in the flash memory.useNativeSHA - Use faster message digest computation. Native C is about 85x faster
than the pure Java version. useNativeSHA=true cannot be
used if NATIVE_VERIFICATION compile flag not set, and
useNativeSHA=false cannot be used if NATIVE_VERIFICATION_ONLY is
set.In this cases verifySuite will throw a RuntimeException
SignatureVerifierException
IOException
protected static void ensureInitialized()
throws SignatureVerifierException
SignatureVerifierException
public static boolean getSuiteVerifiedFlag(int suiteAddress)
throws IllegalArgumentException
IllegalArgumentExceptionpublic static boolean isVerifiedSuite(String uri)
|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||