Commit 7da6bac4 authored by mark burdett's avatar mark burdett
Browse files

Issue #3259960 by mfb: Support BLAKE2b hash algorithm

parent b8066ca9
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -10,14 +10,22 @@ duplicate files to be detected, and allow copies to be verified against the
original source.

File Hash module generates and stores hashes for each file uploaded to the site.
The MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512/224, SHA-512/256, SHA-512,
SHA3-224, SHA3-256, SHA3-384 and SHA3-512 hash algorithms are supported.
The BLAKE2b-128, BLAKE2b-160, BLAKE2b-224, BLAKE2b-256, BLAKE2b-384,
BLAKE2b-512, MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512/224, SHA-512/256,
SHA-512, SHA3-224, SHA3-256, SHA3-384 and SHA3-512 hash algorithms are
supported.

If you need to verify a copy of a file, command-line utilities such as b2sum can
be used to generate identical file hashes.

REQUIREMENTS
------------

Drupal core File module is required.

If you want to use the BLAKE2b hash algorithm, either the Sodium PHP extension
or paragonie/sodium_compat polyfill are required.

INSTALLATION
------------

+6 −0
Original line number Diff line number Diff line
algos:
  blake2b_128: '0'
  blake2b_160: '0'
  blake2b_224: '0'
  blake2b_256: '0'
  blake2b_384: '0'
  blake2b_512: '0'
  md5: '0'
  sha1: '0'
  sha224: '0'
+18 −0
Original line number Diff line number Diff line
@@ -6,6 +6,24 @@ filehash.settings:
      type: mapping
      label: 'Enabled hash algorithms'
      mapping:
        blake2b_128:
          type: string
          label: 'BLAKE2b-128'
        blake2b_160:
          type: string
          label: 'BLAKE2b-160'
        blake2b_224:
          type: string
          label: 'BLAKE2b-224'
        blake2b_256:
          type: string
          label: 'BLAKE2b-256'
        blake2b_384:
          type: string
          label: 'BLAKE2b-384'
        blake2b_512:
          type: string
          label: 'BLAKE2b-512'
        md5:
          type: string
          label: 'MD5'

filehash.css

0 → 100644
+4 −0
Original line number Diff line number Diff line
#edit-algos {
  column-count: auto;
  column-width: 30ch;
}
+22 −0
Original line number Diff line number Diff line
@@ -29,3 +29,25 @@ function filehash_schema() {
  ];
  return $schema;
}

/**
 * Implements hook_requirements().
 */
function filehash_requirements($phase) {
  $requirements = [];
  if ('runtime' === $phase && preg_grep('/^blake/', filehash_columns())) {
    $requirements['filehash_sodium'] = [
      'title' => t('Sodium PHP extension'),
      'description' => t('File Hash is configured to use the BLAKE2b hash algorithm, which requires the Sodium PHP extension.'),
    ];
    if (function_exists('sodium_crypto_generichash_init')) {
      $requirements['filehash_sodium']['value'] = t('Enabled');
      $requirements['filehash_sodium']['severity'] = REQUIREMENT_OK;
    }
    else {
      $requirements['filehash_sodium']['value'] = t('Not enabled');
      $requirements['filehash_sodium']['severity'] = REQUIREMENT_WARNING;
    }
  }
  return $requirements;
}
Loading