RSA BSAFE Cert-C Micro Edition

The power of PKI for the smallest of devices

Digest and MAC Operation Functions

This section details the functions that manage the creation of a digest. Digests can be used in asymmetric algorithms or Message Authentication Code (MAC) operations. MAC operations can be used in symmetric algorithms. Digests are also used as part of the signing and verification process.

Functions

int R_CR_digest_init (R_CR *crypto)
 Initializes a digest generation operation. More...

int R_CR_digest (R_CR *crypto, unsigned char *data, unsigned int dlen, unsigned char *out, unsigned int *out_len)
 Digests a single block of data and calls the implementations of update and final automatically. More...

int R_CR_digest_update (R_CR *crypto, unsigned char *data, unsigned int dlen)
 Digests a block of data. More...

int R_CR_digest_final (R_CR *crypto, unsigned char *out, unsigned int *olen)
 Finalizes the digest process and indicates that all data has been processed by a call to R_CR_digest_update(), and returns the digest. More...

int R_CR_mac_init (R_CR *crypto, R_SKEY *key)
 Initializes a Message Authentication Code (MAC) generation operation. More...

int R_CR_mac (R_CR *crypto, unsigned char *data, unsigned int dlen, unsigned char *out, unsigned int *olen)
 Calculates the Message Authentication Code (MAC) for a single block of data and calls the implementations of update and final automatically. More...

int R_CR_mac_update (R_CR *crypto, unsigned char *data, unsigned int dlen)
 Updates the Message Authentication Code (MAC) for a block of data. More...

int R_CR_mac_final (R_CR *crypto, unsigned char *out, unsigned int *olen)
 Finalizes Message Authentication Code( MAC) processing. More...

int R_CR_verify_mac_init (R_CR *crypto, R_SKEY *key)
 Initializes a Message Authentication Code (MAC) verify operation. More...

int R_CR_verify_mac (R_CR *crypto, unsigned char *data, unsigned int dlen, unsigned char *mac, unsigned int mac_len, int *result)
 Performs Message Authentication Code (MAC) verification for a single block of data. More...

int R_CR_verify_mac_update (R_CR *crypto, unsigned char *data, unsigned int dlen)
 Processes Message Authentication Code (MAC) verification for a block of data. More...

int R_CR_verify_mac_final (R_CR *crypto, unsigned char *mac, unsigned int mac_len, int *result)
 Finalizes the Message Authentication Code (MAC) verify operation. More...


Function Documentation

int R_CR_digest R_CR   crypto,
unsigned char *    data,
unsigned int    data_len,
unsigned char *    out,
unsigned int *    out_len
;
 

Digests a single block of data and calls the implementations of update and final automatically.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_digest_init() respectively.
data [In] A pointer to the data to process.
data_len [In] The number of Bytes to process.
out [Out] The buffer that takes the digest.
Must be of sufficient length to contain the final block of data.
out_len [In, Out] The length of the digest, in out.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_digest_init().

int R_CR_digest_final R_CR   crypto,
unsigned char *    out,
unsigned int *    olen
;
 

Finalizes the digest process and indicates that all data has been processed by a call to R_CR_digest_update(), and returns the digest.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_digest_init() respectively.
out [Out] The buffer that takes the digest.
Must be of sufficient length to contain the final block of data.
olen [In, Out] The length of the digest, in out.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_digest_init() and R_CR_digest_update().

int R_CR_digest_init R_CR   crypto ;
 

Initializes a digest generation operation.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type via R_CR_new().
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_digest_update(), R_CR_digest_final() and R_CR_digest().

int R_CR_digest_update R_CR   crypto,
unsigned char *    data,
unsigned int    data_len
;
 

Digests a block of data. This function can be called multiple times and must be followed by a call to R_CR_digest_final() to obtain the result.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must have been allocated the correct type and initialized by calls to R_CR_new() and R_CR_digest_init() respectively.
data [In] A pointer to the data to process.
data_len [In] The number of Bytes to process.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_digest_init() and R_CR_digest_final().

int R_CR_mac R_CR   crypto,
unsigned char *    data,
unsigned int    data_len,
unsigned char *    out,
unsigned int *    out_len
;
 

Calculates the Message Authentication Code (MAC) for a single block of data and calls the implementations of update and final automatically.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_mac_init() respectively.
data [In] A pointer to the data to process.
data_len [In] The number of Bytes to process.
out [Out] The buffer that takes the MAC.
Must be of sufficient length to contain the encrypted data.
out_len [In, Out] The length of the MAC, in out.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_mac_init().

int R_CR_mac_final R_CR   crypto,
unsigned char *    out,
unsigned int *    out_len
;
 

Finalizes Message Authentication Code( MAC) processing. Indicates that all data has been processed by calls to R_CR_mac_update(), and returns the MAC.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_mac_init() respectively.
out [Out] The buffer that takes the MAC.
Must be of sufficient length to contain the final block of data.
out_len [In, Out] The length of the MAC, in out.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_mac_init() and R_CR_mac_update().

int R_CR_mac_init R_CR   crypto,
R_SKEY   key
;
 

Initializes a Message Authentication Code (MAC) generation operation.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type via R_CR_new().
key [In] The key to use.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_mac_update(), R_CR_mac_final() and R_CR_mac().

int R_CR_mac_update R_CR   crypto,
unsigned char *    data,
unsigned int    data_len
;
 

Updates the Message Authentication Code (MAC) for a block of data. Can be called multiple times and must be followed by a call to R_CR_mac_final() to obtain the result.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_mac_init() respectively.
data [In] A pointer to the data to process.
data_len [Out] The number of Bytes to process.
Cannot be set to NULL.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_mac_init() and R_CR_mac_final().

int R_CR_verify_mac R_CR   crypto,
unsigned char *    data,
unsigned int    data_len,
unsigned char *    mac,
unsigned int    mac_len,
int *    result
;
 

Performs Message Authentication Code (MAC) verification for a single block of data. Calculates the MAC of the data passed in and compares it to the mac passed in. This function encapsulates R_CR_verify_mac_update() and R_CR_verify_mac_final().

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_verify_mac_init() respectively.
data [In] A pointer to the data to process.
data_len [In] The number of Bytes to process.
mac [In] The buffer that takes the MAC.
mac_len [In] The length of the MAC.
result [Out] The result of the MAC comparison.
Cannot be set to NULL.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_verify_mac_init(), R_CR_verify_mac_update() and R_CR_verify_mac_final().

int R_CR_verify_mac_final R_CR   crypto,
unsigned char *    mac,
unsigned int    mac_len,
int *    result
;
 

Finalizes the Message Authentication Code (MAC) verify operation. Indicates that all data has been processed by calls to R_CR_verify_mac_update() and compares the MAC passed in with the previously calculated MAC.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_verify_mac_init() respectively.
mac [In] The buffer that takes the MAC.
mac_len [In] The length of the MAC.
result [Out] The result of the MAC comparison.
Cannot be set to NULL.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_verify_mac_init() and R_CR_verify_mac_update().

int R_CR_verify_mac_init R_CR   crypto,
R_SKEY   key
;
 

Initializes a Message Authentication Code (MAC) verify operation.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type via R_CR_new().
key [In] The key to use.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_verify_mac_update(), R_CR_verify_mac_final() and R_CR_verify_mac().

int R_CR_verify_mac_update R_CR   crypto,
unsigned char *    data,
unsigned int    data_len
;
 

Processes Message Authentication Code (MAC) verification for a block of data. It can be called multiple times and must be followed by a call to R_CR_verify_mac_final() to obtain the result.

Parameters:
crypto [In] A pointer to the cryptographic object.
Must be allocated the correct type and initialized by calls to R_CR_new() and R_CR_verify_mac_init() respectively.
data [In] A pointer to the data to process.
data_len [In] The number of Bytes to process.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.
See also:
R_CR_verify_mac_init() and R_CR_verify_mac_final().


Copyright (c) 1999-2002 RSA Security Inc. All rights reserved. 061-001005-150-001-000-3768 - 1.5