Examples of SecretKeySpec


Examples of javax.crypto.spec.SecretKeySpec

            //Cipher decrypt = Cipher.getInstance("DES");
            //SecretKey key = new SecretKeySpec(pass.getBytes(), "DES");
            Cipher decrypt = Cipher.getInstance("DESede/ECB/NoPadding", "BC");

            SecretKey key = new SecretKeySpec(pass.getBytes(), "DESede");

            decrypt.init(Cipher.DECRYPT_MODE, key);


            // decode base64 zu bytes                               
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

   */
  private static byte[] blowfishCrypt(final byte[] input, final byte[] key, final int mode) throws Exception {
    //final Provider sunJce = new com.sun.crypto.provider.SunJCE();
    //Security.addProvider(sunJce);

    final SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish");
      
    final Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
    cipher.init(mode, skeySpec);

    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

      throw new OSecurityException("Error on generating key for algorithm: " + iAlgorithm, e);
    }
  }

  public SecretKey createKey(final String iAlgorithm, final byte[] iKey) throws OSecurityAccessException {
    return new SecretKeySpec(iKey, iAlgorithm);
  }
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

  /**
   * @param algorithm The algorithm for which to make a key spec
   * @return The key spec according to the length of the key
   */
  private SecretKeySpec createKeySpec (byte[] key, String algorithm) { return new SecretKeySpec(key, algorithm); }
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

                        RANDOM.nextBytes(masterKey);

                        byte[] exchangedKey = new byte[16];
                        try {
                            Cipher rc4 = Cipher.getInstance("RC4");
                            rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(userSessionKey, "RC4"));
                            rc4.update(masterKey, 0, 16, exchangedKey, 0);
                        } catch (GeneralSecurityException gse) {
                            throw new RuntimeException("", gse);
                        }

                        setSessionKey(exchangedKey);
                    } else {
                        masterKey = userSessionKey;
                        setSessionKey(masterKey);
                    }
                }
            }
            break;
        case 2:
            byte[] nt = getNTResponse(type2, password);
            setLMResponse(nt);
            setNTResponse(nt);
            break;
        case 3:
        case 4:
        case 5:
            byte[] responseKeyNT = NtlmPasswordAuthentication.nTOWFv2(domain, user, password);

            byte[] clientChallenge = new byte[8];
            RANDOM.nextBytes(clientChallenge);
            setLMResponse(getLMv2Response(type2, domain, user, password, clientChallenge));

            byte[] clientChallenge2 = new byte[8];
            RANDOM.nextBytes(clientChallenge2);
            setNTResponse(getNTLMv2Response(type2, responseKeyNT, clientChallenge2));

            if ((getFlags() & NTLMSSP_NEGOTIATE_SIGN) == NTLMSSP_NEGOTIATE_SIGN) {
                masterKey = new byte[16];
                RANDOM.nextBytes(masterKey);

                HMACT64 hmac = new HMACT64(responseKeyNT);
                hmac.update(ntResponse, 0, 16); // only first 16 bytes of ntResponse
                byte[] userSessionKey = hmac.digest();

                /* TODO: don't do this if NTLMSSP_NEGOTIATE_KEY_EXCH not set
                 */
                byte[] exchangedKey = new byte[16];
                try {
                    Cipher rc4 = Cipher.getInstance("RC4");
                    rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(userSessionKey, "RC4"));
                    rc4.update(masterKey, 0, 16, exchangedKey, 0);
                } catch (GeneralSecurityException gse) {
                    throw new RuntimeException("", gse);
                }

View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

    byte []keyBytes = new byte[cipher.getBlockSize()];
    for (int i = 0; i < cookie.length() && i < keyBytes.length; i++) {
      keyBytes[i] = (byte) cookie.charAt(i);
    }

    SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
    cipher.init(mode, keySpec);

    return cipher;
  }
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

        properties.setActions(actions);
       
        // Set the key up
        byte[] hmacKey = "secret".getBytes("ASCII");
        String signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#hmac-sha1";
        SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
        properties.setSignatureKey(key);
       
        properties.setSignatureAlgorithm(signatureAlgorithm);
       
        SecurePart securePart = new SecurePart(
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

        properties.setActions(actions);
       
        // Set the key up
        byte[] hmacKey = "secret".getBytes("ASCII");
        String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";
        SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
        properties.setSignatureKey(key);
       
        properties.setSignatureAlgorithm(signatureAlgorithm);
       
        SecurePart securePart = new SecurePart(
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

        properties.setActions(actions);
       
        // Set the key up
        byte[] hmacKey = "secret".getBytes("ASCII");
        String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";
        SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
        properties.setSignatureKey(key);
       
        properties.setSignatureAlgorithm(signatureAlgorithm);
       
        SecurePart securePart = new SecurePart(
View Full Code Here

Examples of javax.crypto.spec.SecretKeySpec

        properties.setActions(actions);
       
        // Set the key up
        byte[] hmacKey = "secret".getBytes("ASCII");
        String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";
        SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
        properties.setSignatureKey(key);
       
        properties.setSignatureAlgorithm(signatureAlgorithm);
       
        SecurePart securePart = new SecurePart(
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.