List of usage examples for org.bouncycastle.crypto Signer update
public void update(byte b);
From source file:org.candlepin.util.DERUtil.java
License:Open Source License
/** * Write an integer as a DER encoded definite length. * * @param out//from w w w .j av a 2 s .c o m * @param length * @throws IOException if something goes wrong */ public static void writeLength(OutputStream out, int length, Signer signer) throws IOException { if (length > 127) { int size = 1; int val = length; while ((val >>>= 8) != 0) { size++; } byte b = (byte) (size | 0x80); out.write(b); if (signer != null) { signer.update(b); } for (int i = (size - 1) * 8; i >= 0; i -= 8) { b = (byte) (length >> i); out.write(b); if (signer != null) { signer.update(b); } } } else { byte b = (byte) length; out.write(b); if (signer != null) { signer.update(b); } } }
From source file:org.candlepin.util.DERUtil.java
License:Open Source License
public static void writeTag(OutputStream out, int tag, int tagNo, Signer signer) throws IOException { int rebuiltTag = rebuildTag(tag, tagNo); out.write(rebuiltTag);/*ww w. java 2 s. co m*/ if (signer != null) { signer.update((byte) rebuiltTag); } }