Exemplo n.º 1
0
 private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
   try {
     EncryptionKey encKey = new EncryptionKey(new DerValue((byte[]) ois.readObject()));
     keyType = encKey.getEType();
     keyBytes = encKey.getBytes();
   } catch (Asn1Exception ae) {
     throw new IOException(ae.getMessage());
   }
 }
Exemplo n.º 2
0
  /**
   * @serialData this <code>KeyImpl</code> is serialized by writing out the ASN1 Encoded bytes of
   *     the encryption key. The ASN1 encoding is defined in RFC4120 and as follows: EncryptionKey
   *     ::= SEQUENCE { keytype [0] Int32 -- actually encryption type --, keyvalue [1] OCTET STRING
   *     }
   */
  private void writeObject(ObjectOutputStream ois) throws IOException {
    if (destroyed) {
      throw new IOException("This key is no longer valid");
    }

    try {
      ois.writeObject((new EncryptionKey(keyType, keyBytes)).asn1Encode());
    } catch (Asn1Exception ae) {
      throw new IOException(ae.getMessage());
    }
  }