suricata
util-crypt.h File Reference
#include "suricata-common.h"
Include dependency graph for util-crypt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Sha1State_
 
union  HashState_
 

Macros

#define SHA1_LENGTH   20
 
#define LOAD32H(x, y)
 
#define STORE64H(x, y)
 
#define STORE32H(x, y)
 
#define ROL(x, y)   ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL)
 
#define ROLc(x, y)   ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL)
 

Typedefs

typedef struct Sha1State_ Sha1State
 
typedef union HashState_ HashState
 

Enumerations

enum  CryptId {
  SC_SHA_1_OK, SC_SHA_1_NOK, SC_SHA_1_INVALID_ARG, SC_BASE64_OK,
  SC_BASE64_INVALID_ARG, SC_BASE64_OVERFLOW
}
 

Functions

int ComputeSHA1 (const uint8_t *inbuf, size_t inbuf_len, uint8_t *outbuf, size_t outbuf_len)
 calculate SHA1 hash More...
 
int Base64Encode (const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
 

Detailed Description

Author
Roliers Jean-Paul popof.nosp@m..fpn.nosp@m.@gmai.nosp@m.l.co

Implements cryptographic functions. Based on the libtomcrypt library ( http://libtom.org/?page=features&newsitems=5&whatfile=crypt )

Definition in file util-crypt.h.

Macro Definition Documentation

◆ LOAD32H

#define LOAD32H (   x,
 
)
Value:
{ x = ((unsigned long)((y)[0] & 255)<<24) | \
((unsigned long)((y)[1] & 255)<<16) | \
((unsigned long)((y)[2] & 255)<<8) | \
((unsigned long)((y)[3] & 255)); }

Definition at line 48 of file util-crypt.h.

◆ ROL

#define ROL (   x,
 
)    ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL)

Definition at line 64 of file util-crypt.h.

◆ ROLc

#define ROLc (   x,
 
)    ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL)

Definition at line 65 of file util-crypt.h.

◆ SHA1_LENGTH

#define SHA1_LENGTH   20

Definition at line 46 of file util-crypt.h.

◆ STORE32H

#define STORE32H (   x,
 
)
Value:
{ (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \
(y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); }

Definition at line 60 of file util-crypt.h.

◆ STORE64H

#define STORE64H (   x,
 
)
Value:
{ (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \
(y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \
(y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \
(y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); }

Definition at line 54 of file util-crypt.h.

Typedef Documentation

◆ HashState

typedef union HashState_ HashState

◆ Sha1State

typedef struct Sha1State_ Sha1State

Enumeration Type Documentation

◆ CryptId

enum CryptId
Enumerator
SC_SHA_1_OK 
SC_SHA_1_NOK 
SC_SHA_1_INVALID_ARG 
SC_BASE64_OK 
SC_BASE64_INVALID_ARG 
SC_BASE64_OVERFLOW 

Definition at line 32 of file util-crypt.h.

Function Documentation

◆ Base64Encode()

int Base64Encode ( const unsigned char *  in,
unsigned long  inlen,
unsigned char *  out,
unsigned long *  outlen 
)

Definition at line 272 of file util-crypt.c.

References SC_BASE64_INVALID_ARG, and SC_BASE64_OVERFLOW.

Referenced by EvePacket(), JsonPacket(), OutputJsonDNP3SetItem(), and StringAsBase64().

Here is the caller graph for this function:

◆ ComputeSHA1()

int ComputeSHA1 ( const uint8_t *  inbuf,
size_t  inbuf_len,
uint8_t *  outbuf,
size_t  outbuf_size 
)

calculate SHA1 hash

Return values
int1 for success, 0 for fail

Definition at line 230 of file util-crypt.c.

References unlikely.