Examples of SHA1Digest


Examples of com.calclab.emite.base.crypto.SHA1Digest

  }

  private final byte[] clientProof() {
    final byte[] saltedPassword = new PBKDF2().doKey(credentials.getPassword().getBytes(), salt, icount);
    final byte[] clientKey = new HMac().doMac(saltedPassword, "Client Key".getBytes());
    final byte[] storedKey = new SHA1Digest().doHash(clientKey);
    final byte[] clientSignature = new HMac().doMac(storedKey, authMessage());
    return XOR(clientKey, clientSignature);
  }
View Full Code Here

Examples of com.dotcms.repackage.org.bouncycastle.crypto.digests.SHA1Digest

    return "XmlToolCache";
  }
 
  private static String hashPath(String path) {
    byte[] data=path.getBytes();
    SHA1Digest digest=new SHA1Digest();
    digest.update(data, 0, data.length);
    byte[] result=new byte[digest.getDigestSize()];
    digest.doFinal(result, 0);
    String ret=null;
    ret=new String(Base64.encode(result));   
    return ret;
  }
View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

      signatureInt = Rsa.removePKCS1(signatureInt, 1);

      signature = signatureInt.toByteArray();

      SHA1Digest h = new SHA1Digest();
      h.update(msg, 0, msg.length);
      byte[] data = new byte[h.getDigestSize()];
      h.doFinal(data, 0);

      if(data.length != (signature.length - ASN_SHA1.length)) {
        return false;
      }
View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

* @see com.maverick.crypto.publickey.RsaPrivateCrtKeyInterface#sign(byte[])
*/
public byte[] sign(byte[] msg) throws IOException {


    SHA1Digest hash = new SHA1Digest();
    hash.update(msg, 0, msg.length);

    byte[] data = new byte[hash.getDigestSize()];
    hash.doFinal(data, 0);


      byte[] tmp = new byte[data.length + ASN_SHA1.length];
      System.arraycopy(ASN_SHA1, 0, tmp, 0, ASN_SHA1.length);
      System.arraycopy(data, 0, tmp, ASN_SHA1.length, data.length);
View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

  /* (non-Javadoc)
* @see com.maverick.crypto.publickey.DsaPrivateKeyInterface#sign(byte[])
*/
public byte[] sign(byte[] msg) {

    SHA1Digest h = new SHA1Digest();
    h.update(msg, 0, msg.length);
    byte[] data = new byte[h.getDigestSize()];
    h.doFinal(data, 0);
    return Dsa.sign(x, p, q, g, data);
  }
View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

   * @throws IOException
   */
  public boolean verifySignature(byte[] signature, byte[] msg) {

      // Create a SHA1 hash of the message
      SHA1Digest h = new SHA1Digest();
      h.update(msg, 0, msg.length);
      byte[] data = new byte[h.getDigestSize()];
      h.doFinal(data, 0);

      return Dsa.verify(y, p, q, g, signature, data);
  }
View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

      byte[] msg,
      BigInteger r,
      BigInteger s) {

    // Create a SHA1 hash of the message
    SHA1Digest h = new SHA1Digest();
    h.update(msg, 0, msg.length);
    byte[] data = new byte[h.getDigestSize()];
    h.doFinal(data, 0);


    BigInteger m = new BigInteger(1, data);
    m = m.mod(q);
View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

* @see com.maverick.crypto.publickey.RsaPrivateKeyInterface#sign(byte[])
*/
public byte[] sign(byte[] msg) throws IOException {


      SHA1Digest hash = new SHA1Digest();
      hash.update(msg, 0, msg.length);

      byte[] data = new byte[hash.getDigestSize()];
      hash.doFinal(data, 0);

      byte[] tmp = new byte[data.length + ASN_SHA1.length];
      System.arraycopy(ASN_SHA1, 0, tmp, 0, ASN_SHA1.length);
      System.arraycopy(data, 0, tmp, ASN_SHA1.length, data.length);
      data = tmp;
View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

  public DSAParameters generateParameters() {
    byte[] seed = new byte[20];
    byte[] part1 = new byte[20];
    byte[] part2 = new byte[20];
    byte[] u = new byte[20];
    SHA1Digest sha1 = new SHA1Digest();
    int n = (size - 1) / 160;
    byte[] w = new byte[size / 8];

    BigInteger q = null, p = null, g = null;
    int counter = 0;
    boolean primesFound = false;

    while (!primesFound) {
      do {
        random.nextBytes(seed);

        sha1.update(seed, 0, seed.length);

        sha1.doFinal(part1, 0);

        System.arraycopy(seed, 0, part2, 0, seed.length);

        add(part2, seed, 1);

        sha1.update(part2, 0, part2.length);

        sha1.doFinal(part2, 0);

        for (int i = 0; i != u.length; i++) {
          u[i] = (byte) (part1[i] ^ part2[i]);
        }

        u[0] |= (byte) 0x80;
        u[19] |= (byte) 0x01;

        q = new BigInteger(1, u);
      }
      while (!q.isProbablePrime(certainty));

      counter = 0;

      int offset = 2;

      while (counter < 4096) {
        for (int k = 0; k < n; k++) {
          add(part1, seed, offset + k);
          sha1.update(part1, 0, part1.length);
          sha1.doFinal(part1, 0);
          System.arraycopy(part1, 0, w, w.length - (k + 1) * part1.length,
                           part1.length);
        }

        add(part1, seed, offset + n);
        sha1.update(part1, 0, part1.length);
        sha1.doFinal(part1, 0);
        System.arraycopy(part1, part1.length - ( (w.length - (n) * part1.length)),
                         w, 0, w.length - n * part1.length);

        w[0] |= (byte) 0x80;

View Full Code Here

Examples of com.maverick.crypto.digests.SHA1Digest

        log.debug(Messages.getString("SSLHandshakeProtocol.calculatingMasterSecret")); //$NON-NLS-1$
        // #endif

        try {
            MD5Digest md5 = new MD5Digest();
            SHA1Digest sha1 = new SHA1Digest();

            ByteArrayOutputStream out = new ByteArrayOutputStream();

            String[] mixers = new String[] { "A", "BB", "CCC" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

            for (int i = 0; i < mixers.length; i++) {
                md5.reset();
                sha1.reset();
                sha1.update(mixers[i].getBytes(), 0, mixers[i].getBytes().length);
                sha1.update(premasterSecret, 0, premasterSecret.length);
                sha1.update(clientRandom, 0, clientRandom.length);
                sha1.update(serverRandom, 0, serverRandom.length);

                md5.update(premasterSecret, 0, premasterSecret.length);
                byte[] tmp = new byte[sha1.getDigestSize()];
                sha1.doFinal(tmp, 0);

                md5.update(tmp, 0, tmp.length);

                tmp = new byte[md5.getDigestSize()];
                md5.doFinal(tmp, 0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.