Examples of SecretKey


Examples of javax.crypto.SecretKey

        super(name);
    }

    public void testGenerateSha1()
    {
        SecretKey secretKey = Association.generateMacSha1Key();

        assertNotNull(secretKey);
        assertTrue(secretKey instanceof SecretKeySpec);

        SecretKeySpec secretKeySpec = (SecretKeySpec) secretKey;
View Full Code Here

Examples of javax.crypto.SecretKey

    public void testGenerateSha256()
    {
        if (Association.isHmacSha256Supported())
        {
            SecretKey secretKey = Association.generateMacSha256Key();

            assertNotNull(secretKey);
            assertTrue(secretKey instanceof SecretKeySpec);

            SecretKeySpec secretKeySpec = (SecretKeySpec) secretKey;
View Full Code Here

Examples of javax.crypto.SecretKey

    * This method returns a secret (symmetric) key. This is for XML Encryption.
    * @return the secret key contained in this KeyInfo
    * @throws KeyResolverException
    */
   public SecretKey getSecretKey() throws KeyResolverException {
      SecretKey sk = this.getSecretKeyFromInternalResolvers();

      if (sk != null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a secret key using the per-KeyInfo key resolvers");

         return sk;
View Full Code Here

Examples of javax.crypto.SecretKey

                  // if we do not have storage resolvers, we verify with null
                  StorageResolver storage = null;

                  if (keyResolver.canResolve((Element) currentChild,
                                             this.getBaseURI(), storage)) {
                     SecretKey sk  =
                        keyResolver.resolveSecretKey((Element) currentChild,
                                                     this.getBaseURI(),
                                                     storage);

                     if (sk != null) {
                        return sk;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.canResolve((Element) currentChild,
                                                this.getBaseURI(), storage)) {
                        SecretKey sk =
                           keyResolver.resolveSecretKey((Element) currentChild,
                                                        this.getBaseURI(),
                                                        storage);

                        if (sk != null) {
View Full Code Here

Examples of javax.crypto.SecretKey

                  StorageResolver storage = null;

                  if (keyResolver.engineCanResolve((Element) currentChild,
                                                   this.getBaseURI(),
                                                   storage)) {
                     SecretKey sk =
                        keyResolver
                           .engineResolveSecretKey((Element) currentChild, this
                              .getBaseURI(), storage);

                     if (sk != null) {
                        return sk;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.engineCanResolve((Element) currentChild,
                                                      this.getBaseURI(),
                                                      storage)) {
                        SecretKey sk = keyResolver
                           .engineResolveSecretKey((Element) currentChild, this
                              .getBaseURI(), storage);

                        if (sk != null) {
                           return sk;
View Full Code Here

Examples of javax.crypto.SecretKey

    public EncryptedKey(char[] password)
            throws Exception {

        KeyGenerator keyGen = KeyGenerator.getInstance(CRYPTO_ALGORITHM);
        keyGen.init(KEY_SIZE);
        SecretKey key = keyGen.generateKey();
        this.secretKey = key;
        this.encryptedKey = getEncrypted(secretKey.getEncoded(), password);
    }
View Full Code Here

Examples of javax.crypto.SecretKey

        /* Create PBE parameter set */
        pbeParamSpec = new PBEParameterSpec(salt, iteration_count);

        pbeKeySpec = new PBEKeySpec(password);
        keyFac = SecretKeyFactory.getInstance(PBE_ALGORITHM);
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

        /* Create PBE Cipher */
        Cipher pbeCipher = Cipher.getInstance(PBE_ALGORITHM);

        /* Initialize PBE Cipher with key and parameters */
 
View Full Code Here

Examples of javax.crypto.SecretKey

        // Create PBE parameter set
        pbeParamSpec = new PBEParameterSpec(salt, count);

        pbeKeySpec = new PBEKeySpec(PWD.toCharArray());
        keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

        // Initialize PBE Cipher with key and parameters
View Full Code Here

Examples of javax.crypto.SecretKey

        // Create PBE parameter set
        pbeParamSpec = new PBEParameterSpec(salt, count);

        pbeKeySpec = new PBEKeySpec(PWD.toCharArray());
        keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

        // Initialize PBE Cipher with key and parameters
View Full Code Here

Examples of javax.crypto.SecretKey

      // 从原始密匙数据创建DESKeySpec对象
      DESKeySpec dks = new DESKeySpec(key);
      // 创建一个密匙工厂,然后用它把DESKeySpec转换成
      // 一个SecretKey对象
      SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(algorithm);
      SecretKey secretKey = keyFactory.generateSecret(dks);
      // Cipher对象实际完成加密操作
      enCipher = Cipher.getInstance(algorithm);
      deCipher = Cipher.getInstance(algorithm);
      // 用密匙初始化Cipher对象
      enCipher.init(Cipher.ENCRYPT_MODE, secretKey, sr);
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.