/** * Deprecated, used only by Packet.java in streaming. * Broken for sig types P521 and RSA before 0.9.15 * @return the written length (NOT the new offset) */ public int writeBytes(byte target[], int offset) { int cur = offset; System.arraycopy(_publicKey.getData(), 0, target, cur, PublicKey.KEYSIZE_BYTES); cur += PublicKey.KEYSIZE_BYTES; if (_padding != null) { System.arraycopy(_padding, 0, target, cur, _padding.length); cur += _padding.length; } int spkTrunc = Math.min(SigningPublicKey.KEYSIZE_BYTES, _signingKey.length()); System.arraycopy(_signingKey.getData(), 0, target, cur, spkTrunc); cur += spkTrunc; cur += _certificate.writeBytes(target, cur); return cur - offset; }
public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_certificate == null) || (_publicKey == null) || (_signingKey == null)) throw new DataFormatException("Not enough data to format the router identity"); _publicKey.writeBytes(out); if (_padding != null) out.write(_padding); else if (_signingKey.length() < SigningPublicKey.KEYSIZE_BYTES) throw new DataFormatException("No padding set"); _signingKey.writeTruncatedBytes(out); _certificate.writeBytes(out); }
/** * */ @Override public byte[] toByteArray() { byte rv[] = new byte[estimateSize()]; int offset = 0; offset += _instructions.writeBytes(rv, offset); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("Wrote instructions: " + _instructions); //offset += _msg.toByteArray(rv); try { byte m[] = _msg.toByteArray(); System.arraycopy(m, 0, rv, offset, m.length); offset += m.length; } catch (RuntimeException e) { throw new RuntimeException("Unable to write: " + _msg + ": " + e.getMessage()); } DataHelper.toLong(rv, offset, 4, _cloveId); offset += 4; DataHelper.toDate(rv, offset, _expiration.getTime()); offset += DataHelper.DATE_LENGTH; offset += _certificate.writeBytes(rv, offset); if (offset != rv.length) { Log log = I2PAppContext.getGlobalContext().logManager().getLog(GarlicClove.class); log.error("Clove offset: " + offset + " but estimated length: " + rv.length); } return rv; }
baos.write(cloves[i]); config.getCertificate().writeBytes(baos); DataHelper.writeLong(baos, 4, config.getId()); DataHelper.writeLong(baos, DataHelper.DATE_LENGTH, config.getExpiration());
pub.writeBytes(keyStream); keys[0].writeBytes(keyStream); // signing pub Certificate.NULL_CERT.writeBytes(keyStream); priv.writeBytes(keyStream); keys[1].writeBytes(keyStream); // signing priv
pub.writeBytes(keyStream); keys[0].writeBytes(keyStream); // signing pub Certificate.NULL_CERT.writeBytes(keyStream); priv.writeBytes(keyStream); keys[1].writeBytes(keyStream); // signing priv