Beispiel #1
0
  static DSAPublicKey parseDSA(DataByteInputStream in) throws IOException {
    byte t = in.readByte();

    BigInteger q = in.readBigInteger(20);
    BigInteger p = in.readBigInteger(64 + t * 8);
    BigInteger g = in.readBigInteger(64 + t * 8);
    BigInteger y = in.readBigInteger(64 + t * 8);

    DSAPublicKey dsa = new DSAPubKey(p, q, g, y);
    return dsa;
  }
Beispiel #2
0
  static RSAPublicKey parseRSA(DataByteInputStream in) throws IOException {
    int exponentLength = in.readUnsignedByte();
    if (exponentLength == 0) exponentLength = in.readUnsignedShort();
    BigInteger exponent = in.readBigInteger(exponentLength);

    int modulusLength = in.available();
    BigInteger modulus = in.readBigInteger(modulusLength);

    RSAPublicKey rsa = new RSAPubKey(modulus, exponent);
    return rsa;
  }
Beispiel #3
0
 KEYRecord(Name _name, short _dclass, int _ttl, int length, DataByteInputStream in, Compression c)
     throws IOException {
   super(_name, Type.KEY, _dclass, _ttl);
   if (in == null) return;
   flags = in.readShort();
   proto = in.readByte();
   alg = in.readByte();
   if (length > 4) {
     key = new byte[length - 4];
     in.read(key);
   }
 }
Beispiel #4
0
 Record rrFromWire(Name name, int type, int dclass, long ttl, int length, DataByteInputStream in)
     throws IOException {
   CERTRecord rec = new CERTRecord(name, dclass, ttl);
   if (in == null) return rec;
   rec.certType = in.readShort();
   rec.keyTag = in.readUnsignedShort();
   rec.alg = in.readByte();
   if (length > 5) {
     rec.cert = new byte[length - 5];
     in.read(rec.cert);
   }
   return rec;
 }
Beispiel #5
0
  static DHPublicKey parseDH(DataByteInputStream in) throws IOException {
    int special = 0;
    int pLength = in.readUnsignedShort();
    if (pLength < 16 && pLength != 1 && pLength != 2) return null;
    BigInteger p;
    if (pLength == 1 || pLength == 2) {
      if (pLength == 1) special = in.readUnsignedByte();
      else special = in.readUnsignedShort();
      if (special != 1 && special != 2) return null;
      if (special == 1) p = DHPRIME768;
      else p = DHPRIME1024;
    } else p = in.readBigInteger(pLength);

    int gLength = in.readUnsignedShort();
    BigInteger g;
    if (gLength == 0) {
      if (special != 0) g = TWO;
      else return null;
    } else g = in.readBigInteger(gLength);

    int yLength = in.readUnsignedShort();
    BigInteger y = in.readBigInteger(yLength);

    return new DHPubKey(p, g, y);
  }
Beispiel #6
0
 protected static Record rrFromWire(SIGBase rec, int length, DataByteInputStream in)
     throws IOException {
   if (in == null) return rec;
   int start = in.getPos();
   rec.covered = in.readUnsignedShort();
   rec.alg = in.readByte();
   rec.labels = in.readByte();
   rec.origttl = in.readUnsignedInt();
   rec.expire = new Date(1000 * (long) in.readInt());
   rec.timeSigned = new Date(1000 * (long) in.readInt());
   rec.footprint = in.readShort();
   rec.signer = new Name(in);
   rec.signature = new byte[length - (in.getPos() - start)];
   in.read(rec.signature);
   return rec;
 }
Beispiel #7
0
 Record rrFromWire(
     Name name, short type, short dclass, int ttl, int length, DataByteInputStream in)
     throws IOException {
   SIGRecord rec = new SIGRecord(name, dclass, ttl);
   if (in == null) return rec;
   int start = in.getPos();
   rec.covered = in.readShort();
   rec.alg = in.readByte();
   rec.labels = in.readByte();
   rec.origttl = in.readInt();
   rec.expire = new Date(1000 * (long) in.readInt());
   rec.timeSigned = new Date(1000 * (long) in.readInt());
   rec.footprint = in.readShort();
   rec.signer = new Name(in);
   rec.signature = new byte[length - (in.getPos() - start)];
   in.read(rec.signature);
   return rec;
 }
Beispiel #8
0
 UNKRecord(
     Name _name,
     short _type,
     short _dclass,
     int _ttl,
     int length,
     DataByteInputStream in,
     Compression c)
     throws IOException {
   super(_name, _type, _dclass, _ttl);
   if (in == null) return;
   if (length > 0) {
     data = new byte[length];
     in.read(data);
   } else data = null;
 }