|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectP2PWNC.P2PWNCProto
P2PWNC.P2PWNCCrypt
This class provides cryptographic functionality, that is methods for performing encryption, decryption, digital signing and verification, etc. for the P2PWNC protocol. The standard SUNJCE provider is used.
Field Summary | |
static int |
P2PWNC_ALGO_ECC
Elliptic Curve cryptosystem identifier. |
static int |
P2PWNC_ALGO_RSA
RSA cryptosystem identifier. |
static int |
P2PWNC_MSG_CACK
This message type corresponds to a P2PWNC "connection acknowledgement" message (CACK). |
static int |
P2PWNC_MSG_CONN
This message type corresponds to a P2PWNC "connect" message (CONN). |
static int |
P2PWNC_MSG_RCPT
This message type corresponds to a P2PWNC "receipt" message (RCPT). |
static int |
P2PWNC_MSG_RREQ
This message type corresponds to a P2PWNC "receipt request" message (RREQ). |
static int |
P2PWNC_MSG_TEAR
This message type corresponds to a P2PWNC "tear connection" message (TEAR). |
static int |
P2PWNC_SERVER_PORT
The standard port a service provider listens for client messages, as specified by the P2PWNC protocol). |
Constructor Summary | |
(package private) |
P2PWNCCrypt()
Default constructor (does nothing in special, since there are no fields to initialize) |
Method Summary | |
P2PWNCReceipt |
constructReceipt(P2PWNCCert cert,
P2PWNCKey prov,
int timestamp,
int weight,
P2PWNCKey key,
boolean pub)
Constructs and signs a P2PWNC receipt. |
protected byte[] |
cryptMessage(byte[] message,
P2PWNCKey key,
int cipherMode,
boolean pub)
Encrypts or decrypts a message using a specified P2PWNCKey ("key" parameter). |
static void |
cryptTest(P2PWNCKey priv,
P2PWNCKey pub,
byte[] data)
|
protected java.security.Key |
internalToKey(P2PWNCKey key,
boolean pub)
Constructs a Key object from the specified P2PWNCKey input parameter. |
protected java.security.spec.KeySpec |
internalToKeySpec(P2PWNCKey key,
boolean pub)
Converts from internal key representation to Java KeySpec. |
static byte[] |
reverseByteOrder(byte[] arr)
Reverses the order of the bytes in the input byte array. |
protected byte[] |
serializeReceiptInfo(P2PWNCCert cert,
P2PWNCKey prov,
int timestamp,
int weight)
Serializes the information contained in a P2PWNC receipt. |
protected P2PWNCSignature |
signMessage(P2PWNCKey key,
byte[] message,
boolean pub)
Signs a message using the specified key. |
protected boolean |
verifySignature(P2PWNCSignature signature,
P2PWNCKey key,
byte[] message,
boolean pub)
Verifies a P2PWNCSignature. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int P2PWNC_SERVER_PORT
public static final int P2PWNC_ALGO_RSA
public static final int P2PWNC_ALGO_ECC
public static final int P2PWNC_MSG_RCPT
public static final int P2PWNC_MSG_CONN
public static final int P2PWNC_MSG_RREQ
public static final int P2PWNC_MSG_CACK
public static final int P2PWNC_MSG_TEAR
Constructor Detail |
P2PWNCCrypt()
Method Detail |
public static byte[] reverseByteOrder(byte[] arr)
arr
- byte[]
The byte array whose elements will be reversed.
protected java.security.spec.KeySpec internalToKeySpec(P2PWNCKey key, boolean pub)
key
- P2PWNCKey
The P2PWNCKey from which a KeySpec will result.pub
- boolean
True if key is public and false if it is a secret key.
protected java.security.Key internalToKey(P2PWNCKey key, boolean pub)
key
- P2PWNCKey
The P2PWNCKey object from which a Key object will result.pub
- boolean
True if key is public and false if it is secret.
protected byte[] cryptMessage(byte[] message, P2PWNCKey key, int cipherMode, boolean pub)
message
- byte[]
The message to be encrypted/decrypted.key
- P2PWNCKey
The P2PWNCKey key that will be used for the encryption/decryption operation. This key is first
converted from P2PWNC internal representation to a JCE-specific object (for example
RSAPubliKey) using the internalToKey method.cipherMode
- int
Indicates whether the message is to be encrypted or decrypted. Legal values are Cipher.ENCRYPT_MODE and
Cipher.DECRYPT_MODE.pub
- boolean
True if key is public and false if it is secret.
protected P2PWNCSignature signMessage(P2PWNCKey key, byte[] message, boolean pub)
key
- P2PWNCKey
The key that will be used for signing.message
- byte[]
The original byte array that is to be signed.pub
- boolean
True if key is public.
protected boolean verifySignature(P2PWNCSignature signature, P2PWNCKey key, byte[] message, boolean pub)
signature
- P2PWNCSignature
The P2PWNCSignature that is to be verified.key
- P2PWNCKey
The key that will be used for signature verification.message
- byte[]
The original data, from which the signature has resulted.pub
- boolean
True if key is public.
protected byte[] serializeReceiptInfo(P2PWNCCert cert, P2PWNCKey prov, int timestamp, int weight)
cert
- P2PWNCCert
The client certificate that is included in the receipt.prov
- P2PWNCKey
The service provider public key.timestamp
- int
The session timestamp (number of seconds since the Epoch).weight
- int
Session weight (traffic uploaded/downloaded by a client during the session, measured in bytes).
public P2PWNCReceipt constructReceipt(P2PWNCCert cert, P2PWNCKey prov, int timestamp, int weight, P2PWNCKey key, boolean pub)
cert
- P2PWNCCert
Client certificate that will be included in the receipt.prov
- P2PWNCKey
Service provider public key that will be included in the receipt.timestamp
- int
The session timestamp (number of seconds since the Epoch).weight
- int
Session weight (traffic uploaded/downloaded by a client during the session, measured in bytes).key
- P2PWNCKey
The key that will be used to sign the receipt.pub
- boolean
True if key is public.
public static void cryptTest(P2PWNCKey priv, P2PWNCKey pub, byte[] data) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.SignatureException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |