Package java.security.spec

Examples of java.security.spec.KeySpec


                }

                keyblob = bar.readBinaryString();

                Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
                KeySpec keyspec = new DESedeKeySpec(keydata);
                Key key = SecretKeyFactory.getInstance("DESede").generateSecret(keyspec);
                cipher.init(Cipher.DECRYPT_MODE, key,
                    new IvParameterSpec(iv, 0, cipher.getBlockSize()));

                ByteArrayReader data = new ByteArrayReader(cipher.doFinal(
View Full Code Here


                    byte[] iv = new byte[8];
                    ConfigurationLoader.getRND().nextBytes(iv);

                    Cipher cipher = Cipher.getInstance(
                            "DESede/CBC/PKCS5Padding");
                    KeySpec keyspec = new DESedeKeySpec(keydata);
                    Key key = SecretKeyFactory.getInstance("DESede")
                                              .generateSecret(keyspec);
                    cipher.init(Cipher.ENCRYPT_MODE, key,
                        new IvParameterSpec(iv, 0, cipher.getBlockSize()));
View Full Code Here

    if (saltValue == null || saltValue.length() == 0)
      throw new ManifoldCFException("Missing required SALT value");
   
    SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
    KeySpec keySpec = new PBEKeySpec(passCode.toCharArray(), saltValue.getBytes(), 1024, 128);
    SecretKey secretKey = factory.generateSecret(keySpec);

    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    SecretKeySpec key = new SecretKeySpec(secretKey.getEncoded(), "AES");
    IvParameterSpec parameterSpec = new IvParameterSpec(iv);
View Full Code Here

        // Iteration count
        int iterationCount = 19;

        try {

            KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
            SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);

            ecipher = Cipher.getInstance("PBEWithMD5AndDES");
            dcipher = Cipher.getInstance("PBEWithMD5AndDES");
View Full Code Here

    }

    private PublicKey readPublicKey(String endMarker)
        throws IOException
    {
        KeySpec keySpec = new X509EncodedKeySpec(readBytes(endMarker));
        String[] algorithms = { "DSA", "RSA" };
        for (int i = 0; i < algorithms.length; i++)
        {
            try
            {
View Full Code Here

            keyBytes = PEMUtilities.crypt(false, provider, keyBytes, password, dekAlgName, iv);
        }


        KeySpec                 pubSpec, privSpec;
        ASN1Sequence            seq = (ASN1Sequence)ASN1Object.fromByteArray(keyBytes);

        if (type.equals("RSA"))
        {
//            DERInteger              v = (DERInteger)seq.getObjectAt(0);
View Full Code Here

    {
        int         keyType = dIn.read();
        String      format = dIn.readUTF();
        String      algorithm = dIn.readUTF();
        byte[]      enc = new byte[dIn.readInt()];
        KeySpec     spec;

        dIn.readFully(enc);

        if (format.equals("PKCS#8") || format.equals("PKCS8"))
        {
View Full Code Here

        charPassword[i] = (char) (password[i] + 256); // cope with signed -> unsigned
      }
    }
    try {
      SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
      KeySpec spec = new PBEKeySpec(charPassword, salt, rounds, 8 * outputByteCount);
      return factory.generateSecret(spec).getEncoded();
    } catch (NoSuchAlgorithmException e) {
      throw new NigoriCryptographyException(e);
    } catch (InvalidKeySpecException e) {
      throw new NigoriCryptographyException(e);
View Full Code Here

  public static PublicKey getPublicKey(PKCS10CertificationRequest csr)
      throws InvalidKeySpecException, IOException {
    SubjectPublicKeyInfo pubKeyInfo = csr.getSubjectPublicKeyInfo();
    RSAKeyParameters keyParams = (RSAKeyParameters) PublicKeyFactory
        .createKey(pubKeyInfo);
    KeySpec keySpec = new RSAPublicKeySpec(keyParams.getModulus(),
        keyParams.getExponent());

    KeyFactory kf;
    try {
      kf = KeyFactory.getInstance("RSA");
View Full Code Here

  private static Key key;

  private static Key getKey() throws GeneralSecurityException {
    if(key == null) {
      final KeySpec keySpec = new DESKeySpec(encKey);
      final SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(CIPHER_TRANSFORMATION);
      key = keyFactory.generateSecret(keySpec);
    }
    return key;
  }
View Full Code Here

TOP

Related Classes of java.security.spec.KeySpec

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.