Recipe Name:
Crypto: Signature: Non Standard Hashing Algorithm
Description:
This hashing algorithm is not recommended for cryptographic use
Level:
warning
Language:
  • java
Tags:
  • security
  • basic protection set
Documentation

Secure coding practices prescribe to use SHA512 with RSA for cryptographic use of hashing.

It is not recommended to use cryptographic algorithms and modes with known problems. For hashing, SHA512withRSA is the recommended algorithm.

Correct code example
Signature.getInstance("SHA512withRSA");
Recipe
id: scw:crypto:signature-non-standard-algos
version: 10
metadata:
  name: 'Crypto: Signature: Non Standard Hashing Algorithm'
  shortDescription: This hashing algorithm is not recommended for cryptographic use
  level: warning
  language: java
  newCodeOnly: false
  scwCategory: broken_cryptography:use_of_insecuredeprecated_alogirthms
  enabled: true
  descriptionFile: Java/Crypto/descriptions/Insecure_signature_algorithm.html
  tags: security;basic protection set
search:
  methodcall:
    args:
      1:
        type: java.lang.String
        value:
          stringified:
            matches: SHA512withDSA|SHA512withDES|SHA512withECDSA
    name: getInstance
    declaration:
      type: java.security.Signature
availableFixes:
- name: Use SHA512withRSA
  actions:
  - rewrite:
      to: '{{{ expressionElement }}}("SHA512withRSA")'