Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.crypto.key
Class OutgoingMessage  view OutgoingMessage download OutgoingMessage.java

java.lang.Object
  extended bygnu.javax.crypto.key.OutgoingMessage

public class OutgoingMessage
extends java.lang.Object

An implementation of outgoing messages for use with key agreement protocols.


Field Summary
private  java.io.ByteArrayOutputStream out
          The internal output stream.
 
Constructor Summary
OutgoingMessage()
           
 
Method Summary
private  int getKeyType(java.security.Key k)
           
 byte[] toByteArray()
          Returns the encoded form of the current message including the 4-byte length header.
 byte[] wrap()
          Returns the encoded form of the current message excluding the 4-byte length header.
private  void writeKey(java.security.Key k)
           
 void writeMPI(java.math.BigInteger val)
          Encodes an MPI into the message.
 void writePrivateKey(java.security.PrivateKey k)
          Encodes a private key into the message.
 void writePublicKey(java.security.PublicKey k)
          Encodes a public key into the message.
 void writeString(java.lang.String s)
          Encodes a string into the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

private java.io.ByteArrayOutputStream out
The internal output stream.

Constructor Detail

OutgoingMessage

public OutgoingMessage()
Method Detail

toByteArray

public byte[] toByteArray()
                   throws KeyAgreementException

Returns the encoded form of the current message including the 4-byte length header.


wrap

public byte[] wrap()
            throws KeyAgreementException

Returns the encoded form of the current message excluding the 4-byte length header.


writePublicKey

public void writePublicKey(java.security.PublicKey k)
                    throws KeyAgreementException
Encodes a public key into the message.

When a public key is encoded into an outgoing message, the byte array of the encoded key --according to its encoding/decoding format specified when the key was first instantiated-- are put in the message (a) preceeded by one byte representing both the type of key (upper 4-bit) and the identifier of the format used (lower 4-bit), and (b) preceeed by a 4-byte entity representing the total length, excluding these 4 bytes, of the bytes representing the encoded key and the one-byte representing the key-type and format; i.e.

    key --> 4-byte-length || 1-byte-type-and-format || encoded-key-bytes
 


writePrivateKey

public void writePrivateKey(java.security.PrivateKey k)
                     throws KeyAgreementException
Encodes a private key into the message.

When a private key is encoded into an outgoing message, the byte array of the encoded key --according to its encoding/decoding format specified when the key was first instantiated-- are put in the message (a) preceeded by one byte representing both the type of key (upper 4-bit) and the identifier of the format used (lower 4-bit), and (b) preceeed by a 4-byte entity representing the total length, excluding these 4 bytes, of the bytes representing the encoded key and the one-byte representing the key-type and format; i.e.

    key --> 4-byte-length || 1-byte-type-and-format || encoded-key-bytes
 


writeMPI

public void writeMPI(java.math.BigInteger val)
              throws KeyAgreementException

Encodes an MPI into the message.


writeString

public void writeString(java.lang.String s)
                 throws KeyAgreementException

Encodes a string into the message.


writeKey

private void writeKey(java.security.Key k)
               throws KeyAgreementException

getKeyType

private int getKeyType(java.security.Key k)
                throws KeyAgreementException