rpm  4.18.0
Typedefs | Enumerations | Functions
RPM crypto API.

RPM cryptography related APIs and constants. More...

Typedefs

typedef struct DIGEST_CTX_s * DIGEST_CTX
 
typedef enum rpmHashAlgo_e rpmHashAlgo
 At this time these simply mirror PGPHASHALGO numbers. More...
 

Enumerations

enum  rpmHashAlgo_e {
  RPM_HASH_MD5 = 1 , RPM_HASH_SHA1 = 2 , RPM_HASH_RIPEMD160 = 3 , RPM_HASH_MD2 = 5 ,
  RPM_HASH_TIGER192 = 6 , RPM_HASH_HAVAL_5_160 = 7 , RPM_HASH_SHA256 = 8 , RPM_HASH_SHA384 = 9 ,
  RPM_HASH_SHA512 = 10 , RPM_HASH_SHA224 = 11
}
 At this time these simply mirror PGPHASHALGO numbers. More...
 
enum  rpmDigestFlags_e { RPMDIGEST_NONE = 0 }
 Bit(s) to control digest operation. More...
 

Functions

int rpmInitCrypto (void)
 Perform cryptography initialization. More...
 
int rpmFreeCrypto (void)
 Shutdown cryptography. More...
 
DIGEST_CTX rpmDigestDup (DIGEST_CTX octx)
 Duplicate a digest context. More...
 
size_t rpmDigestLength (int hashalgo)
 Obtain digest length in bytes. More...
 
DIGEST_CTX rpmDigestInit (int hashalgo, rpmDigestFlags flags)
 Initialize digest. More...
 
int rpmDigestUpdate (DIGEST_CTX ctx, const void *data, size_t len)
 Update context with next plain text buffer. More...
 
int rpmDigestFinal (DIGEST_CTX ctx, void **datap, size_t *lenp, int asAscii)
 Return digest and destroy context. More...
 
rpmDigestBundle rpmDigestBundleNew (void)
 Create a new digest bundle. More...
 
rpmDigestBundle rpmDigestBundleFree (rpmDigestBundle bundle)
 Free a digest bundle and all contained digest contexts. More...
 
int rpmDigestBundleAdd (rpmDigestBundle bundle, int algo, rpmDigestFlags flags)
 Add a new type of digest to a bundle. More...
 
int rpmDigestBundleAddID (rpmDigestBundle bundle, int algo, int id, rpmDigestFlags flags)
 Add a new type of digest to a bundle. More...
 
int rpmDigestBundleUpdate (rpmDigestBundle bundle, const void *data, size_t len)
 Update contexts within bundle with next plain text buffer. More...
 
int rpmDigestBundleFinal (rpmDigestBundle bundle, int id, void **datap, size_t *lenp, int asAscii)
 Return digest from a bundle and destroy context, see rpmDigestFinal(). More...
 
DIGEST_CTX rpmDigestBundleDupCtx (rpmDigestBundle bundle, int id)
 Duplicate a digest context from a bundle. More...
 

Detailed Description

RPM cryptography related APIs and constants.

Typedef Documentation

◆ DIGEST_CTX

typedef struct DIGEST_CTX_s* DIGEST_CTX

Definition at line 12 of file rpmcrypto.h.

◆ rpmHashAlgo

typedef enum rpmHashAlgo_e rpmHashAlgo

At this time these simply mirror PGPHASHALGO numbers.

Once they start * growing apart we'll need converters.

Enumeration Type Documentation

◆ rpmDigestFlags_e

Bit(s) to control digest operation.

Enumerator
RPMDIGEST_NONE 

Definition at line 35 of file rpmcrypto.h.

◆ rpmHashAlgo_e

At this time these simply mirror PGPHASHALGO numbers.

Once they start * growing apart we'll need converters.

Enumerator
RPM_HASH_MD5 

MD5

RPM_HASH_SHA1 

SHA1

RPM_HASH_RIPEMD160 

RIPEMD160

RPM_HASH_MD2 

MD2

RPM_HASH_TIGER192 

TIGER192

RPM_HASH_HAVAL_5_160 

HAVAL-5-160

RPM_HASH_SHA256 

SHA256

RPM_HASH_SHA384 

SHA384

RPM_HASH_SHA512 

SHA512

RPM_HASH_SHA224 

SHA224

Definition at line 19 of file rpmcrypto.h.

Function Documentation

◆ rpmDigestBundleAdd()

int rpmDigestBundleAdd ( rpmDigestBundle  bundle,
int  algo,
rpmDigestFlags  flags 
)

Add a new type of digest to a bundle.

Same as calling rpmDigestBundleAddID() with algo == id value.

Parameters
bundledigest bundle
algotype of digest
flagsbit(s) to control digest operation
Returns
0 on success

◆ rpmDigestBundleAddID()

int rpmDigestBundleAddID ( rpmDigestBundle  bundle,
int  algo,
int  id,
rpmDigestFlags  flags 
)

Add a new type of digest to a bundle.

Parameters
bundledigest bundle
algotype of digest
idid of digest (arbitrary, must be > 0)
flagsbit(s) to control digest operation
Returns
0 on success

◆ rpmDigestBundleDupCtx()

DIGEST_CTX rpmDigestBundleDupCtx ( rpmDigestBundle  bundle,
int  id 
)

Duplicate a digest context from a bundle.

Parameters
bundledigest bundle
idid of digest to dup
Returns
duplicated digest context

◆ rpmDigestBundleFinal()

int rpmDigestBundleFinal ( rpmDigestBundle  bundle,
int  id,
void **  datap,
size_t *  lenp,
int  asAscii 
)

Return digest from a bundle and destroy context, see rpmDigestFinal().

Parameters
bundledigest bundle
idid of digest to return
[out]datapaddress of returned digest
[out]lenpaddress of digest length
asAsciireturn digest as ascii string?
Returns
0 on success

◆ rpmDigestBundleFree()

rpmDigestBundle rpmDigestBundleFree ( rpmDigestBundle  bundle)

Free a digest bundle and all contained digest contexts.

Parameters
bundledigest bundle
Returns
NULL always

◆ rpmDigestBundleNew()

rpmDigestBundle rpmDigestBundleNew ( void  )

Create a new digest bundle.

Returns
New digest bundle

◆ rpmDigestBundleUpdate()

int rpmDigestBundleUpdate ( rpmDigestBundle  bundle,
const void *  data,
size_t  len 
)

Update contexts within bundle with next plain text buffer.

Parameters
bundledigest bundle
datanext data buffer
lenno. bytes of data
Returns
0 on success

◆ rpmDigestDup()

DIGEST_CTX rpmDigestDup ( DIGEST_CTX  octx)

Duplicate a digest context.

Parameters
octxexisting digest context
Returns
duplicated digest context

◆ rpmDigestFinal()

int rpmDigestFinal ( DIGEST_CTX  ctx,
void **  datap,
size_t *  lenp,
int  asAscii 
)

Return digest and destroy context.

Final wrapup - pad to 64-byte boundary with the bit pattern 1 0* (64-bit count of bits processed, MSB-first)

Parameters
ctxdigest context
[out]datapaddress of returned digest
[out]lenpaddress of digest length
asAsciireturn digest as ascii string?
Returns
0 on success

◆ rpmDigestInit()

DIGEST_CTX rpmDigestInit ( int  hashalgo,
rpmDigestFlags  flags 
)

Initialize digest.

Set bit count to 0 and buffer to mysterious initialization constants.

Parameters
hashalgotype of digest
flagsbit(s) to control digest operation
Returns
digest context

◆ rpmDigestLength()

size_t rpmDigestLength ( int  hashalgo)

Obtain digest length in bytes.

Parameters
hashalgotype of digest
Returns
digest length, zero on invalid algorithm

◆ rpmDigestUpdate()

int rpmDigestUpdate ( DIGEST_CTX  ctx,
const void *  data,
size_t  len 
)

Update context with next plain text buffer.

Parameters
ctxdigest context
datanext data buffer
lenno. bytes of data
Returns
0 on success

◆ rpmFreeCrypto()

int rpmFreeCrypto ( void  )

Shutdown cryptography.

◆ rpmInitCrypto()

int rpmInitCrypto ( void  )

Perform cryptography initialization.

It must be called before any cryptography can be used within rpm. It's not normally necessary to call it directly as it's called in general rpm initialization routines.

Returns
0 on success, -1 on failure