/** * Number of bytes, NOT including signature */ public int size() { return _destination.size() + PublicKey.KEYSIZE_BYTES // encryptionKey + _signingKey.length() // signingKey + 1 // number of leases + _leases.size() * 44; }
/** * Number of bytes, NOT including signature */ @Override public int size() { int rv = _signingKey.length() + 12; if (_encryptedData != null) rv += _encryptedData.length; else rv += 99; // TODO if (isOffline()) rv += 6 + _transientSigningPublicKey.length() + _offlineSignature.length(); return rv; }
/** * @since 0.9.8 */ @Override public String toString() { StringBuilder buf = new StringBuilder(64); buf.append("[SigningPublicKey ").append((_type != null) ? _type.toString() : "unknown type").append(' '); int length = length(); if (_data == null) { buf.append("null"); } else if (length <= 32) { buf.append(toBase64()); } else { buf.append("size: ").append(length); } buf.append(']'); return buf.toString(); }
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, 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; }
/** * Number of bytes, NOT including signature */ @Override public int size() { int rv = _destination.size() + 10 + (_leases.size() * MetaLease.LENGTH); if (isOffline()) rv += 6 + _transientSigningPublicKey.length() + _offlineSignature.length(); if (_options != null && !_options.isEmpty()) { try { rv += DataHelper.toProperties(_options).length; } catch (DataFormatException dfe) { throw new IllegalStateException("bad options", dfe); } } else { rv += 2; } // revocations TODO // rv += 32 * numRevocations return rv; }
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); }
/** * Only for SigType EdDSA_SHA512_Ed25519. * * @param key must be SigType EdDSA_SHA512_Ed25519 * @param h hash of secret data, same length as this key * @throws UnsupportedOperationException unless supported */ public static SigningPublicKey blind(SigningPublicKey key, SimpleDataStructure h) { if (key.getType() != TYPE) throw new UnsupportedOperationException(); if (h.length() != key.length()) throw new IllegalArgumentException(); try { EdDSAPublicKey jk = SigUtil.toJavaEdDSAKey(key); EdDSAPublicKey bjk = EdDSABlinding.blind(jk, h.getData()); return SigUtil.fromJavaKey(bjk, TYPE); } catch (GeneralSecurityException gse) { throw new IllegalArgumentException(gse); } }
/** * Number of bytes, NOT including signature */ @Override public int size() { int rv = _destination.size() + 10 + (_leases.size() * Lease2.LENGTH); for (PublicKey key : getEncryptionKeys()) { rv += 4; rv += key.length(); } if (isOffline()) rv += 6 + _transientSigningPublicKey.length() + _offlineSignature.length(); if (_options != null && !_options.isEmpty()) { try { rv += DataHelper.toProperties(_options).length; } catch (DataFormatException dfe) { throw new IllegalStateException("bad options", dfe); } } else { rv += 2; } return rv; }
/** * Overridden because we have a blinded key, not a dest. * This is the hash of the signing public key type and the signing public key. * Throws IllegalStateException if not initialized. * * @throws IllegalStateException */ @Override public Hash getHash() { if (__calculatedHash == null) { if (_signingKey == null) throw new IllegalStateException(); int len = _signingKey.length(); byte[] b = new byte[2 + len]; DataHelper.toLong(b, 0, 2, _signingKey.getType().getCode()); System.arraycopy(_signingKey.getData(), 0, b, 2, len); __calculatedHash = SHA256Generator.getInstance().calculateHash(b); } return __calculatedHash; }
byte[] data = new byte[4 + 2 + tSigningPubKey.length()]; DataHelper.toLong(data, 0, 4, expires / 1000); DataHelper.toLong(data, 4, 2, tstype.getCode()); System.arraycopy(tSigningPubKey.getData(), 0, data, 6, tSigningPubKey.length()); Signature sign = DSAEngine.getInstance().sign(data, pkf.getSigningPrivKey()); if (sign == null)
d.setSigningPublicKey(signingPubKey); d.setCertificate(cert); int len = signingPubKey.length(); if (len < 128) { byte[] pad = new byte[128 - len];
ident.setSigningPublicKey(signingPubKey); byte[] padding; int padLen = SigningPublicKey.KEYSIZE_BYTES - signingPubKey.length(); if (padLen > 0) { padding = new byte[padLen];