GithubHelp home page GithubHelp logo

Comments (8)

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

I'm not so sure it'll work. Do you have any test code on how are you successfully using it without jasypt?

from jasypt-spring-boot.

schacko3 avatar schacko3 commented on May 12, 2024

Hi -  can clean up the code and send later . But are you aware of jasypt working with any FIPS compliant provider before ? Thanks 

from jasypt-spring-boot.

schacko3 avatar schacko3 commented on May 12, 2024

would you know of anyway I can get more debug out of the jasypt cmd line tools? Then I can investigate the root cause of the FIPSRuntimeException I get when I try to encrypt via jasypt cmd line..

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

I'm not aware of any integration at the moment. Jasypt is open source and the cmd line tool is quite simple, you can download the code or check it out here. That service class is used by the CLI classes that are called from scripts you're using.

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

In any case, an example of what you're doing would be the only way I'd be able to help you

from jasypt-spring-boot.

schacko3 avatar schacko3 commented on May 12, 2024

What we had been doing paraphrased below. Would like to do the same using jasypt's property files alone, or at least minimal programming:

IBMJCEFIPS ibmJCEFIPSProvider = new com.ibm.crypto.fips.provider.IBMJCEFIPS();
public static void main(String[] args) {

    String plainText = "What to encrypt" ;


    byte[] keyBytes =   generateEncodedFIPSAESKeyBytes();

    String key = encodeBase64String(keyBytes);
    System.out.println(key);

    SecretKeySpec secretObj = null;

    secretObj = new SecretKeySpec(keyBytes,"AES");

    try {
        Cipher cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.ENCRYPT_MODE, secretObj);

        // Encrypt the input text from the cipher
        byte[] encryptedTextBytes = cipher.doFinal(plainText.getBytes(UTF_8));

         String encrypted = new String(encodeBase64(encryptedTextBytes));

         System.out.println(encrypted);
    } catch (InvalidKeyException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchPaddingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalBlockSizeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (BadPaddingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

public String generateEncodedFIPSAESKey() {
    Security.addProvider(ibmJCEFIPSProvider);
    try {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES", ibmJCEFIPSProvider);
        keyGen.init(KEY_SIZE_128);

        SecretKey secKey = keyGen.generateKey();
        byte[] keyBytes = secKey.getEncoded();
        return encodeBase64String(keyBytes);
    } catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

It seems like all you gotta do is to implement StringEncryptor to use it with this plugin:

public interface StringEncryptor {


    /**
     * Encrypt the input message
     * 
     * @param message the message to be encrypted
     * @return the result of encryption
     */
    public String encrypt(String message);


    /**
     * Decrypt an encrypted message
     * 
     * @param encryptedMessage the encrypted message to be decrypted
     * @return the result of decryption
     */
    public String decrypt(String encryptedMessage);

}

And then follow the guide in the Readme to hook in your own encryptor, which is basically just defining a @Bean:

@Bean(name="encryptorBean")
    static public StringEncryptor stringEncryptor() {
        return new YourFIPSStringEncryptor();
    }

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

where can I get this? com.ibm.crypto.fips.provider.IBMJCEFIPS

from jasypt-spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.