Package javax.crypto.spec

Examples of javax.crypto.spec.SecretKeySpec


     
        // hash is 20 bytes so we've got 4 zeros at the end. tough
     
      System.arraycopy( hash, 0, key_data, 0, hash.length );
     
      SecretKey tdes_key = new SecretKeySpec( key_data, "DESede" );

      Cipher cipher = Cipher.getInstance("DESede")// Triple-DES encryption

      cipher.init(mode, tdes_key );
           
View Full Code Here


        synchronized(this) {
            keyBytes=asymCipher.doFinal(encodedKey);
        }

        SecretKeySpec keySpec=null;
        try {
            keySpec=new SecretKeySpec(keyBytes, getAlgorithm(symAlgorithm));

            // test reconstituted key to see if valid
            Cipher temp;
            if (symProvider != null && symProvider.trim().length() > 0)
                temp=Cipher.getInstance(symAlgorithm, symProvider);
View Full Code Here

   * @return A decrypted Properies object with all of the properties from the
   *         CentraView Customer server.
   */
  private static final Key decryptBlowfishKey(byte[] encryptedKey)
  {
    SecretKeySpec blowfishKey = null;
    try {
      X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(PUBLIC_KEY);
      KeyFactory keyFactory = KeyFactory.getInstance("RSA");
      RSAPublicKey publicKey = (RSAPublicKey)keyFactory.generatePublic(publicKeySpec);

      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.DECRYPT_MODE, publicKey);

      byte[] blowfishKeyByteArray = cipher.doFinal(encryptedKey);
      blowfishKey = new SecretKeySpec(blowfishKeyByteArray, "Blowfish");
    } catch (Exception exception) {
      logger.error("[decryptBlowfishKey] Exception thrown.", exception);
    }
    return blowfishKey;
  } //end of decryptServerProperties method
View Full Code Here

     * @param key
     * @return a new SymmetricCryptor
     * @throws CryptoException
     */
    public static SymmetricCryptor getSymmectricCryptor(byte[] key) throws CryptoException {
        Key secretKey = new SecretKeySpec(key, DEFAULT_SYM_KEY_ALGORITHM);
        return new SymmetricCryptor(secretKey);
    }
View Full Code Here

      }
     
      try{
        byte[]  shared_secret = sts_engine.getSharedSecret();
               
          SecretKeySpec  secret_key_spec1 = new SecretKeySpec(shared_secret, 0, 16, "AES" );
          SecretKeySpec  secret_key_spec2 = new SecretKeySpec(shared_secret, 8, 16, "AES" );
           
          AlgorithmParameterSpec  param_spec1 =   new IvParameterSpec( AES_IV1);
          AlgorithmParameterSpec  param_spec2 =   new IvParameterSpec( AES_IV2);     
             
          Cipher cipher1 = Cipher.getInstance( "AES/CBC/PKCS5Padding" );
View Full Code Here

                             boolean urlencode) {
            // The following HMAC/SHA1 code for the signature is taken from the
            // AWS Platform's implementation of RFC2104 (amazon.webservices.common.Signature)
            //
            // Acquire an HMAC/SHA1 from the raw key bytes.
            SecretKeySpec signingKey=
                    new SecretKeySpec(awsSecretAccessKey.getBytes(), HMAC_SHA1_ALGORITHM);

            // Acquire the MAC instance and initialize with the signing key.
            Mac mac=null;
            try {
                mac=Mac.getInstance(HMAC_SHA1_ALGORITHM);
View Full Code Here

           
        dh_key_generator.generateKeyPair();
                    
          byte[]  rc4_test_secret = new byte[RC4_STREAM_KEY_SIZE_BYTES];
 
          SecretKeySpec  rc4_test_secret_key_spec = new SecretKeySpec(rc4_test_secret, 0, RC4_STREAM_KEY_SIZE_BYTES, RC4_STREAM_ALG );
                         
          TransportCipher rc4_cipher = new TransportCipher( RC4_STREAM_CIPHER, Cipher.ENCRYPT_MODE, rc4_test_secret_key_spec );
              
          rc4_cipher = new TransportCipher( RC4_STREAM_CIPHER, Cipher.DECRYPT_MODE, rc4_test_secret_key_spec );
           
View Full Code Here

        hasher.update( secret_bytes );
        hasher.update( shared_secret );
         
        byte[]  b_key = hasher.getDigest();
       
        SecretKeySpec  secret_key_spec_a = new SecretKeySpec( a_key, RC4_STREAM_ALG );
           
        SecretKeySpec  secret_key_spec_b = new SecretKeySpec( b_key, RC4_STREAM_ALG );
                     
        write_cipher   = new TransportCipher( RC4_STREAM_CIPHER, Cipher.ENCRYPT_MODE, outbound?secret_key_spec_a:secret_key_spec_b );
         
        read_cipher   = new TransportCipher( RC4_STREAM_CIPHER, Cipher.DECRYPT_MODE, outbound?secret_key_spec_b:secret_key_spec_a );
       
View Full Code Here

 
  protected RC4Engine
  getCipher(
    byte[]      key )
  {
      SecretKeySpec  secret_key_spec = new SecretKeySpec( key, "RC4" );
     
      RC4Engine rc4_engine  = new RC4Engine();
   
    CipherParameters  params_a = new KeyParameter( secret_key_spec.getEncoded());
   
      // for RC4 enc/dec is irrelevant
   
    rc4_engine.init( true, params_a );
   
View Full Code Here

    }

    protected SecretKey engineGenerateSecret(
        String algorithm)
    {
        return new SecretKeySpec(result.toByteArray(), algorithm);
    }
View Full Code Here

TOP

Related Classes of javax.crypto.spec.SecretKeySpec

Copyright © 2018 www.massapicom. 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.