Package java.math

Examples of java.math.BigInteger.toByteArray()


      BigInteger B_v = B.subtract(v);
      if( log.isTraceEnabled() )
         log.trace("B - v: "+CryptoUtil.tob64(B_v.toByteArray()));
      BigInteger a_ux = a.add(u.multiply(x));
      if( log.isTraceEnabled() )
         log.trace("a + u * x: "+CryptoUtil.tob64(a_ux.toByteArray()));
      BigInteger S = B_v.modPow(a_ux, N);
      if( log.isTraceEnabled() )
         log.trace("S: "+CryptoUtil.tob64(S.toByteArray()));
      // K = SessionHash(S)
      MessageDigest sessionDigest = MessageDigest.getInstance(params.hashAlgorithm);
View Full Code Here


      BigInteger a_ux = a.add(u.multiply(x));
      if( log.isTraceEnabled() )
         log.trace("a + u * x: "+CryptoUtil.tob64(a_ux.toByteArray()));
      BigInteger S = B_v.modPow(a_ux, N);
      if( log.isTraceEnabled() )
         log.trace("S: "+CryptoUtil.tob64(S.toByteArray()));
      // K = SessionHash(S)
      MessageDigest sessionDigest = MessageDigest.getInstance(params.hashAlgorithm);
      K = sessionDigest.digest(S.toByteArray());
      if( log.isTraceEnabled() )
         log.trace("K: "+CryptoUtil.tob64(K));
View Full Code Here

      }

      TstImpl(char[] password, String salt)
      {
         BigInteger N = SRPConf.getDefaultParams().N();
         log.trace("N: "+Util.tob64(N.toByteArray()));
         BigInteger g = SRPConf.getDefaultParams().g();
         log.trace("g: "+Util.tob64(g.toByteArray()));
         byte[] Nb = SRPConf.getDefaultParams().Nbytes();
         log.trace("N': "+Util.tob64(params.N));
         byte[] gb = SRPConf.getDefaultParams().gbytes();
View Full Code Here

      BigInteger S = B_v.modPow(a_ux, N);
      if( log.isTraceEnabled() )
         log.trace("S: "+CryptoUtil.tob64(S.toByteArray()));
      // K = SessionHash(S)
      MessageDigest sessionDigest = MessageDigest.getInstance(params.hashAlgorithm);
      K = sessionDigest.digest(S.toByteArray());
      if( log.isTraceEnabled() )
         log.trace("K: "+CryptoUtil.tob64(K));
      // clientHash = H(N) xor H(g) | H(U) | A | B | K
      clientHash.update(K);
      byte[] M1 = clientHash.digest();
View Full Code Here

      TstImpl(char[] password, String salt)
      {
         BigInteger N = SRPConf.getDefaultParams().N();
         log.trace("N: "+Util.tob64(N.toByteArray()));
         BigInteger g = SRPConf.getDefaultParams().g();
         log.trace("g: "+Util.tob64(g.toByteArray()));
         byte[] Nb = SRPConf.getDefaultParams().Nbytes();
         log.trace("N': "+Util.tob64(params.N));
         byte[] gb = SRPConf.getDefaultParams().gbytes();
         log.trace("g': "+Util.tob64(params.g));
         byte[] hn = Util.newDigest().digest(params.N);
View Full Code Here

      signatureInt = Rsa.doPublic(signatureInt,
                                  getModulus(), publicExponent);

      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);
View Full Code Here

            if (key instanceof RsaPublicKey) {

                BigInteger padded = Rsa.padPKCS1(input, 0x02, 128);
                BigInteger s = Rsa.doPublic(padded, ((RsaPublicKey) key).getModulus(), ((RsaPublicKey) key).getPublicExponent());

                secret = s.toByteArray();
            } else {
                throw new SSLException(SSLException.UNSUPPORTED_CERTIFICATE);
            }
        } catch (CertificateException ex) {
            throw new SSLException(SSLException.UNSUPPORTED_CERTIFICATE, ex.getMessage());
View Full Code Here

                            BigInteger input = new BigInteger(blob);
                            RsaPublicKey r = (RsaPublicKey) trusted.getPublicKey();
                            BigInteger decoded = Rsa.doPublic(input, r.getModulus(), r.getPublicExponent());
                            BigInteger result = Rsa.removePKCS1(decoded, 0x01);
                            byte[] sig = result.toByteArray();

                            MD5Digest digest = new MD5Digest();
                            digest.update(x509.getTBSCertificate(), 0, x509.getTBSCertificate().length);
                            byte[] hash = new byte[digest.getDigestSize()];
                            digest.doFinal(hash, 0);
View Full Code Here

                            RsaPublicKey r = (RsaPublicKey) trusted.getPublicKey();

                            BigInteger decoded = Rsa.doPublic(input, r.getModulus(), r.getPublicExponent());

                            BigInteger result = Rsa.removePKCS1(decoded, 0x01);
                            byte[] sig = result.toByteArray();

                            SHA1Digest digest = new SHA1Digest();
                            digest.update(x509.getTBSCertificate(), 0, x509.getTBSCertificate().length);
                            byte[] hash = new byte[digest.getDigestSize()];
                            digest.doFinal(hash, 0);
View Full Code Here

    protected void writeDecimal(BigDecimal o, Type type) {

        int        scale   = o.scale();
        BigInteger bigint  = JavaSystem.unscaledValue(o);
        byte[]     bytearr = bigint.toByteArray();

        writeByteArray(bytearr);
        writeInt(scale);
    }
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.