hu_MACMsg()

Computes the MAC output on the given data using the specified key.

Synopsis:

#include "humac.h"
 
int hu_MACMsg(sb_Key macKey, size_t dataLen, const unsigned char *data, size_t *tagLen, unsigned char *tag, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

macKey

The MAC key object.

dataLen

The length (in bytes) of the data.

data

The data value.

tagLen

The length (in bytes) of the tag.

tag

The MAC output.

sbCtx

A global context.

Library:

libhuapi (For the qcc command, use the -l huapi option to link against this library)

Description:

To specify the length of the tag value, a pointer to a buffer large enough to hold the tag value should be passed in tag and its length in tagLen. This function will copy the first tagLen bytes of the computed tag into tag. If tagLen is greater than the default tag length, the entire tag value is copied, and the default length of the tag value is set in tagLen.

If tag is NULL, then this function will set the default length of the tag value in tagLen. If tag is not NULL but tagLen is too small, this function will return an error and will also set the default length of the tag value in tagLen.

For HMAC algorithms, the default length of the tag value is the underlying digest's output length. The minimum length of the tag value is half the default length.

For cipher-based MAC algorithms, the default length of the tag value is the block length of the underlying cipher. The minimum length of the tag value is half the default length.

Returns:

SB_ERR_NULL_KEY

The macKey object is NULL.

SB_ERR_BAD_KEY

The macKey object is invalid.

SB_ERR_NULL_OUTPUT_BUF_LEN_PTR

The tagLen pointer is NULL.

SB_ERR_BAD_OUTPUT_BUF_LEN

The tagLen value is too small.

Last modified: 2014-05-14



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus