General remarks



Web applications and HTTP

Books



JAAS



JCE - Encryption - Message Digests

Using JCE I am getting a BadPaddingException?. What should I do?
Search the forums for BadPaddingException for several discussions on this. The gist is: don't use a String to store the encrypted text - use byte[].

Where can I get Java source code for the XYZ algorithm?
Bouncycastle is an open source library comprised of many and varied encryption algorithms, amongst them a full JCE implementation. The codes for the AES competition are also available. Those include Rijndael (which became AES), RC6, Serpent, Twofish and Mars.

I am getting an java.lang.SecurityException?: Unsupported keysize or algorithm parameters. What gives?
One reason may be that you're using incorrect parameters for the algorithm, mode or cipher. Check the above-mentioned list of algorithms for what is available. Another reason may be that you don't have the unlimited jurisdiction policy files installed; these can be downloaded from the same place you download the JDK.

How can I implement my own JCE provider?
This is described in detail in the article How To Implement a Provider for the Java Cryptography Architecture. Information on how to install the provider can be found in the sections on "How Provider Implementations Are Requested and Supplied" and "Installing Providers" in this article.

Which message digest (or hash) algorithm should I use?
At this point, the various RC, MD and SHA-1 algorithms should no longer be used. SHA-2 is the way to go; it's available in Java in the SHA-256, SHA-384 and SHA-512 variants. (A NIST competition has selected a SHA-3 standard, but it's not yet part of the JRE, and anyway offers no fundamental advantage over SHA-2.)


Libraries that help implement security features

  • Apache Shiro is a powerful and flexible open-source security framework that cleanly handles authentication, authorization, enterprise session management and cryptography. Don't implement security on your own - use Shiro and be done with it.
  • Google Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse, Guide to Google Tink
  • OWASP's CSRFGuard project, which helps guard your web app against -wait for it- CSRF attacks.
  • Single Sign-On (SSO) can be implemented with CAS, JOSSO, OpenAM (formerly OpenSSO) (looks dormant) or SPNEGO (for Windows authentication, looks dormant)
  • OACC focuses on providing a fully featured API to both enforce and manage an application's authentication and authorization needs
  • Cognicrypt allows developers to quickly identify and fix security-critical misuses of JCA, JSSE, BouncyCastle?, BouncyCastle? as a JCA provider, and Google Tink. article CogniCrypt: Kryptografie richtig nutzen (in German)
  • Spring Security Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications.
  • portecle is a user friendly GUI application for creating, managing and examining keystores, keys, certificates, certificate requests, certificate revocation lists and more
  • Bouncycastle is an open source library comprised of many and varied encryption algorithms, amongst them a full JCE implementation.


Other topics



CategoryJava