public int estimateSize() { return _instructions.getSize() + _msg.getMessageSize() + 4 // cloveId + DataHelper.DATE_LENGTH + _certificate.size(); // certificate }
public int size() { int rv = PublicKey.KEYSIZE_BYTES + _signingKey.length(); if (_certificate.getCertificateType() == Certificate.CERTIFICATE_TYPE_KEY) { // cert data included in keys rv += 7; if (_padding != null) rv += _padding.length; } else { rv += _certificate.size(); } return rv; }
/** * deprecated was used only by Packet.java in streaming, now unused * Warning - used by i2p-bote. Does NOT support alternate key types. DSA-SHA1 only. * * @throws IllegalStateException if data already set */ public int readBytes(byte source[], int offset) throws DataFormatException { if (source == null) throw new DataFormatException("Null source"); if (source.length <= offset + PublicKey.KEYSIZE_BYTES + SigningPublicKey.KEYSIZE_BYTES) throw new DataFormatException("Not enough data (len=" + source.length + " off=" + offset + ")"); if (_publicKey != null || _signingKey != null || _certificate != null) throw new IllegalStateException(); int cur = offset; _publicKey = PublicKey.create(source, cur); cur += PublicKey.KEYSIZE_BYTES; _signingKey = SigningPublicKey.create(source, cur); cur += SigningPublicKey.KEYSIZE_BYTES; _certificate = Certificate.create(source, cur); cur += _certificate.size(); return cur - offset; }
offset += cert.size(); long msgId = DataHelper.fromLong(data, offset, 4); offset += 4;
/** * */ public int readBytes(byte source[], int offset) throws DataFormatException { int cur = offset; _instructions = DeliveryInstructions.create(source, offset); cur += _instructions.getSize(); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("Read instructions: " + _instructions); try { I2NPMessageHandler handler = new I2NPMessageHandler(_context); cur += handler.readMessage(source, cur); _msg = handler.lastRead(); } catch (I2NPMessageException ime) { throw new DataFormatException("Unable to read the message from a garlic clove", ime); } _cloveId = DataHelper.fromLong(source, cur, 4); cur += 4; _expiration = DataHelper.fromDate(source, cur); cur += DataHelper.DATE_LENGTH; //if (_log.shouldLog(Log.DEBUG)) // _log.debug("CloveID read: " + _cloveId + " expiration read: " + _expiration); //_certificate = new Certificate(); //cur += _certificate.readBytes(source, cur); _certificate = Certificate.create(source, cur); cur += _certificate.size(); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("Read cert: " + _certificate); return cur - offset; }