/** * 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; }
/** * @throws IllegalStateException if data already set */ public void readBytes(InputStream in) throws DataFormatException, IOException { if (_publicKey != null || _signingKey != null || _certificate != null) throw new IllegalStateException(); _publicKey = PublicKey.create(in); SigningPublicKey spk = SigningPublicKey.create(in); Certificate cert = Certificate.create(in); if (cert.getCertificateType() == Certificate.CERTIFICATE_TYPE_KEY) { // convert SPK to new SPK and padding KeyCertificate kcert = cert.toKeyCertificate(); _signingKey = spk.toTypedKey(kcert); _padding = spk.getPadding(kcert); _certificate = kcert; } else { _signingKey = spk; _certificate = cert; } }
SigningPublicKey sk = SigningPublicKey.create(in); Certificate c = Certificate.create(in); byte[] padding;