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

#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 47 of file util-crypt.h.

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

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

#define ROLc (   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.

#define SHA1_LENGTH   20

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

Referenced by DetectTransformSha1Register(), and SSLVersionToString().

#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 59 of file util-crypt.h.

#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 53 of file util-crypt.h.

Typedef Documentation

typedef union HashState_ HashState
typedef struct Sha1State_ Sha1State

Enumeration Type Documentation

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

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, SC_BASE64_OK, and SC_BASE64_OVERFLOW.

Referenced by OutputJsonRegister().

Here is the caller graph for this function:

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 ComputeSHA1(), rlen, and unlikely.

Referenced by ComputeSHA1(), OutputJsonRegister(), and SSLVersionToString().

Here is the call graph for this function:

Here is the caller graph for this function: