~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/crypto/internal/blake2b.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/crypto/internal/blake2b.h (Version linux-6.12-rc7) and /include/crypto/internal/blake2b.h (Version linux-2.4.37.11)


  1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */       1 
  2 /*                                                
  3  * Helper functions for BLAKE2b implementation    
  4  * Keep this in sync with the corresponding BL    
  5  */                                               
  6                                                   
  7 #ifndef _CRYPTO_INTERNAL_BLAKE2B_H                
  8 #define _CRYPTO_INTERNAL_BLAKE2B_H                
  9                                                   
 10 #include <crypto/blake2b.h>                       
 11 #include <crypto/internal/hash.h>                 
 12 #include <linux/string.h>                         
 13                                                   
 14 void blake2b_compress_generic(struct blake2b_s    
 15                               const u8 *block,    
 16                                                   
 17 static inline void blake2b_set_lastblock(struc    
 18 {                                                 
 19         state->f[0] = -1;                         
 20 }                                                 
 21                                                   
 22 typedef void (*blake2b_compress_t)(struct blak    
 23                                    const u8 *b    
 24                                                   
 25 static inline void __blake2b_update(struct bla    
 26                                     const u8 *    
 27                                     blake2b_co    
 28 {                                                 
 29         const size_t fill = BLAKE2B_BLOCK_SIZE    
 30                                                   
 31         if (unlikely(!inlen))                     
 32                 return;                           
 33         if (inlen > fill) {                       
 34                 memcpy(state->buf + state->buf    
 35                 (*compress)(state, state->buf,    
 36                 state->buflen = 0;                
 37                 in += fill;                       
 38                 inlen -= fill;                    
 39         }                                         
 40         if (inlen > BLAKE2B_BLOCK_SIZE) {         
 41                 const size_t nblocks = DIV_ROU    
 42                 /* Hash one less (full) block     
 43                 (*compress)(state, in, nblocks    
 44                 in += BLAKE2B_BLOCK_SIZE * (nb    
 45                 inlen -= BLAKE2B_BLOCK_SIZE *     
 46         }                                         
 47         memcpy(state->buf + state->buflen, in,    
 48         state->buflen += inlen;                   
 49 }                                                 
 50                                                   
 51 static inline void __blake2b_final(struct blak    
 52                                    blake2b_com    
 53 {                                                 
 54         int i;                                    
 55                                                   
 56         blake2b_set_lastblock(state);             
 57         memset(state->buf + state->buflen, 0,     
 58                BLAKE2B_BLOCK_SIZE - state->buf    
 59         (*compress)(state, state->buf, 1, stat    
 60         for (i = 0; i < ARRAY_SIZE(state->h);     
 61                 __cpu_to_le64s(&state->h[i]);     
 62         memcpy(out, state->h, state->outlen);     
 63 }                                                 
 64                                                   
 65 /* Helper functions for shash implementations     
 66                                                   
 67 struct blake2b_tfm_ctx {                          
 68         u8 key[BLAKE2B_KEY_SIZE];                 
 69         unsigned int keylen;                      
 70 };                                                
 71                                                   
 72 static inline int crypto_blake2b_setkey(struct    
 73                                         const     
 74 {                                                 
 75         struct blake2b_tfm_ctx *tctx = crypto_    
 76                                                   
 77         if (keylen == 0 || keylen > BLAKE2B_KE    
 78                 return -EINVAL;                   
 79                                                   
 80         memcpy(tctx->key, key, keylen);           
 81         tctx->keylen = keylen;                    
 82                                                   
 83         return 0;                                 
 84 }                                                 
 85                                                   
 86 static inline int crypto_blake2b_init(struct s    
 87 {                                                 
 88         const struct blake2b_tfm_ctx *tctx = c    
 89         struct blake2b_state *state = shash_de    
 90         unsigned int outlen = crypto_shash_dig    
 91                                                   
 92         __blake2b_init(state, outlen, tctx->ke    
 93         return 0;                                 
 94 }                                                 
 95                                                   
 96 static inline int crypto_blake2b_update(struct    
 97                                         const     
 98                                         blake2    
 99 {                                                 
100         struct blake2b_state *state = shash_de    
101                                                   
102         __blake2b_update(state, in, inlen, com    
103         return 0;                                 
104 }                                                 
105                                                   
106 static inline int crypto_blake2b_final(struct     
107                                        blake2b    
108 {                                                 
109         struct blake2b_state *state = shash_de    
110                                                   
111         __blake2b_final(state, out, compress);    
112         return 0;                                 
113 }                                                 
114                                                   
115 #endif /* _CRYPTO_INTERNAL_BLAKE2B_H */           
116                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php