Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  blake2s-generic.c

  Sprache: C
 

// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
 * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
 *
 * This is an implementation of the BLAKE2s hash and PRF functions.
 *
 * Information: https://blake2.net/
 *
 */


#include <crypto/internal/blake2s.h>
#include <linux/bug.h>
#include <linux/export.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/unaligned.h>

static const u8 blake2s_sigma[10][16] = {
 { 0123456789101112131415 },
 { 1410489151361120211753 },
 { 1181205215131014367194 },
 { 7931131211142651040158 },
 { 9057241015141111268313 },
 { 2126100118341375151419 },
 { 1251151413410076392811 },
 { 1311714121395015486210 },
 { 6151491130812213714105 },
 { 1028476151511914312130 },
};

static inline void blake2s_increment_counter(struct blake2s_state *state,
          const u32 inc)
{
 state->t[0] += inc;
 state->t[1] += (state->t[0] < inc);
}

void blake2s_compress(struct blake2s_state *state, const u8 *block,
        size_t nblocks, const u32 inc)
        __weak __alias(blake2s_compress_generic);

void blake2s_compress_generic(struct blake2s_state *state, const u8 *block,
         size_t nblocks, const u32 inc)
{
 u32 m[16];
 u32 v[16];
 int i;

 WARN_ON(IS_ENABLED(DEBUG) &&
  (nblocks > 1 && inc != BLAKE2S_BLOCK_SIZE));

 while (nblocks > 0) {
  blake2s_increment_counter(state, inc);
  memcpy(m, block, BLAKE2S_BLOCK_SIZE);
  le32_to_cpu_array(m, ARRAY_SIZE(m));
  memcpy(v, state->h, 32);
  v[ 8] = BLAKE2S_IV0;
  v[ 9] = BLAKE2S_IV1;
  v[10] = BLAKE2S_IV2;
  v[11] = BLAKE2S_IV3;
  v[12] = BLAKE2S_IV4 ^ state->t[0];
  v[13] = BLAKE2S_IV5 ^ state->t[1];
  v[14] = BLAKE2S_IV6 ^ state->f[0];
  v[15] = BLAKE2S_IV7 ^ state->f[1];

#define G(r, i, a, b, c, d) do { \
 a += b + m[blake2s_sigma[r][2 * i + 0]]; \
 d = ror32(d ^ a, 16); \
 c += d; \
 b = ror32(b ^ c, 12); \
 a += b + m[blake2s_sigma[r][2 * i + 1]]; \
 d = ror32(d ^ a, 8); \
 c += d; \
 b = ror32(b ^ c, 7); \
while (0)

#define ROUND(r) do { \
 G(r, 0, v[0], v[ 4], v[ 8], v[12]); \
 G(r, 1, v[1], v[ 5], v[ 9], v[13]); \
 G(r, 2, v[2], v[ 6], v[10], v[14]); \
 G(r, 3, v[3], v[ 7], v[11], v[15]); \
 G(r, 4, v[0], v[ 5], v[10], v[15]); \
 G(r, 5, v[1], v[ 6], v[11], v[12]); \
 G(r, 6, v[2], v[ 7], v[ 8], v[13]); \
 G(r, 7, v[3], v[ 4], v[ 9], v[14]); \
while (0)
  ROUND(0);
  ROUND(1);
  ROUND(2);
  ROUND(3);
  ROUND(4);
  ROUND(5);
  ROUND(6);
  ROUND(7);
  ROUND(8);
  ROUND(9);

#undef G
#undef ROUND

  for (i = 0; i < 8; ++i)
   state->h[i] ^= v[i] ^ v[i + 8];

  block += BLAKE2S_BLOCK_SIZE;
  --nblocks;
 }
}

EXPORT_SYMBOL(blake2s_compress_generic);

Messung V0.5 in Prozent
C=95 H=92 G=93

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-06-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik