Exemplo n.º 1
0
  public ECDSACryptoSignature build() {

    byte[] bytes = new byte[digest.getDigestSize()];
    digest.doFinal(bytes, 0);
    digest.reset();
    log(meta, bytes);
    ECDSACryptoSignature sig = CryptoFactory.INSTANCE.sign(meta, sKey, bytes);
    for (String ref : references) {
      sig.addDataReference(ref);
    }
    references.clear();
    log(meta, count);
    count = 0;
    return sig;
  }
Exemplo n.º 2
0
 public ECDSASignatureBuilder update(String label, byte[] bytes) {
   if (bytes == null) throw new RuntimeException("Input is null: " + label);
   references.add(label);
   count += bytes.length;
   log(label, bytes);
   digest.update(bytes, 0, bytes.length);
   return this;
 }
Exemplo n.º 3
0
 public ECDSASignatureBuilder update(String label, String input) {
   if (input == null) throw new RuntimeException("Input is null: " + label);
   references.add(label);
   byte[] bytes = input.getBytes(Charset.forName("UTF-8"));
   count += bytes.length;
   log(label, bytes);
   digest.update(bytes, 0, bytes.length);
   return this;
 }
Exemplo n.º 4
0
 /**
  * By default this constructor updates SignedBy and SignedWith, so even with no other calls to
  * update you get a meaningful signature out of build()
  *
  * @param signedBy
  * @param sKey
  */
 public ECDSASignatureBuilder(String signedBy, ECKeyContents sKey) {
   super();
   this.sKey = sKey;
   this.digest = new SHA1Digest();
   this.references = new ArrayList<String>();
   this.signedBy = signedBy;
   if (signedBy == null) throw new RuntimeException("Registration Handle cannot be null");
   meta =
       new SignatureMetadata(
           SignatureAlgorithm.ECDSA, digest.getAlgorithmName(), sKey.getHandle(), signedBy);
   update(meta.getHandle() + ":SignedBy", signedBy);
   update(".SignedWith", sKey.getHandle());
 }