public static DSAEngine getInstance() { return I2PAppContext.getGlobalContext().dsa(); }
versionHeaderInputStream = new ByteArrayInputStream(versionHeader); bytesToSignInputStream = new SequenceInputStream(versionHeaderInputStream, fileInputStream); signature = _context.dsa().sign(bytesToSignInputStream, signingPrivateKey);
rv = _context.dsa().verifySignature(signature, hash, _signerPubkey); } else { rv = true;
/** * Generate a Signature to pass to setOfflineSignature() * * @param expires absolute ms * @param transientSPK the key that will sign the leaseset * @param priv the private signing key for the destination * @return null on error */ public static Signature offlineSign(long expires, SigningPublicKey transientSPK, SigningPrivateKey priv) { ByteArrayOutputStream baos = new ByteArrayOutputStream(128); try { DataHelper.writeLong(baos, 4, expires / 1000); DataHelper.writeLong(baos, 2, transientSPK.getType().getCode()); transientSPK.writeBytes(baos); } catch (IOException ioe) { return null; } catch (DataFormatException dfe) { return null; } byte[] data = baos.toByteArray(); I2PAppContext ctx = I2PAppContext.getGlobalContext(); return ctx.dsa().sign(data, priv); }
return _context.dsa().verifySignature(signature, fileInputStream, signingPublicKey); } catch (IOException ioe) { if (_log.shouldLog(Log.WARN))
SimpleDataStructure hash = sigType.getHashInstance(); hash.setData(sha); Signature signature = _context.dsa().sign(hash, privkey, sigType); if (signature == null) throw new IOException("sig fail");
protected boolean verifyOfflineSignature(SigningPublicKey spk) { if (!isOffline()) return false; I2PAppContext ctx = I2PAppContext.getGlobalContext(); if (_transientExpires < ctx.clock().now()) return false; ByteArrayOutputStream baos = new ByteArrayOutputStream(128); try { DataHelper.writeLong(baos, 4, _transientExpires / 1000); DataHelper.writeLong(baos, 2, _transientSigningPublicKey.getType().getCode()); _transientSigningPublicKey.writeBytes(baos); } catch (IOException ioe) { return false; } catch (DataFormatException dfe) { return false; } byte[] data = baos.toByteArray(); return ctx.dsa().verifySignature(_offlineSignature, data, 0, data.length, getSigningPublicKey()); }
SigningPrivateKey key = _session.getPrivateKey(); int size = writePacket(buffer, offset, key.getType().getSigLen()); _optionSignature = _context.dsa().sign(buffer, offset, size, key); if (_optionSignature == null) throw new IllegalStateException("Signature failed");
_optionSignature = new Signature(type, _optionSignature.getData()); boolean ok = ctx.dsa().verifySignature(_optionSignature, buffer, 0, size, spk); if (!ok) { Log l = ctx.logManager().getLog(Packet.class);
SigningPrivateKey key = _session.getPrivateKey(); int size = writePacket(buffer, offset, key.getType().getSigLen()); _optionSignature = _context.dsa().sign(buffer, offset, size, key); if (_optionSignature == null) throw new IllegalStateException("Signature failed");
_optionSignature = new Signature(type, _optionSignature.getData()); boolean ok = ctx.dsa().verifySignature(_optionSignature, buffer, 0, size, spk); if (!ok) { Log l = ctx.logManager().getLog(Packet.class);