Blame usr/lib/common/p11util.h

Packit Service 0210bb
/*
Packit Service 0210bb
 * COPYRIGHT (c) International Business Machines Corp. 2001-2017
Packit Service 0210bb
 *
Packit Service 0210bb
 * This program is provided under the terms of the Common Public License,
Packit Service 0210bb
 * version 1.0 (CPL-1.0). Any use, reproduction or distribution for this
Packit Service 0210bb
 * software constitutes recipient's acceptance of CPL-1.0 terms which can be
Packit Service 0210bb
 * found in the file LICENSE file or at
Packit Service 0210bb
 * https://opensource.org/licenses/cpl1.0.php
Packit Service 0210bb
 */
Packit Service 0210bb
Packit Service 0210bb
#ifndef _P11UTIL_H_
Packit Service 0210bb
#define _P11UTIL_H_
Packit Service 0210bb
Packit Service 0210bb
Packit Service 0210bb
#include "pkcs11types.h"
Packit Service 0210bb
Packit Service 0210bb
//
Packit Service 0210bb
// p11_get_ckr - return textual interpretation of a CKR_ error code
Packit Service 0210bb
// @rc is the CKR_.. error
Packit Service 0210bb
//
Packit Service 0210bb
char *p11_get_ckr(CK_RV rc);
Packit Service 0210bb
//
Packit Service 0210bb
// p11_get_ckm - return textual interpretation of a CKM_ mechanism code
Packit Service 0210bb
// @rc is the CKM_.. as a string
Packit Service 0210bb
//
Packit Service 0210bb
char *p11_get_ckm(CK_ULONG);
Packit Service 0210bb
Packit Service 0210bb
// is_attribute_defined()
Packit Service 0210bb
//
Packit Service 0210bb
// determine whether the specified attribute is defined by Cryptoki
Packit Service 0210bb
//
Packit Service 0210bb
CK_BBOOL is_attribute_defined(CK_ATTRIBUTE_TYPE type);
Packit Service 0210bb
Packit Service 0210bb
// Allocates memory on *dst and puts hex dump from ptr
Packit Service 0210bb
// with len bytes.
Packit Service 0210bb
// *dst must be freed by the caller
Packit Service 0210bb
char *p11_ahex_dump(char **dst, CK_BYTE_PTR ptr, CK_ULONG len);
Packit Service 0210bb
Packit Service 0210bb
/* p11_bigint_trim() - trim a big integer. Returns pointer that is
Packit Service 0210bb
 *        contained within 'in' + '*size' that represents
Packit Service 0210bb
 *        the same number, but without leading zeros.
Packit Service 0210bb
 *  @in   points to a sequence of bytes forming a big integer,
Packit Service 0210bb
 *        unsigned, right-aligned and big-endian
Packit Service 0210bb
 *  @size points to the size of @in on input, and the minimum
Packit Service 0210bb
 *        size that can represent it on output
Packit Service 0210bb
 */
Packit Service 0210bb
CK_BYTE_PTR p11_bigint_trim(CK_BYTE_PTR in, CK_ULONG_PTR size);
Packit Service 0210bb
Packit Service 0210bb
/* p11_attribute_trim() - trim a PKCS#11 CK_ATTRIBUTE in place,
Packit Service 0210bb
 *      using memmove() to move the data and adjusting
Packit Service 0210bb
 *      ulValueLen. The resulting "pValue" pointer stays the
Packit Service 0210bb
 *      same so that the caller can free() it normally
Packit Service 0210bb
 * @attr is the pointer to the CK_ATTRIBUTE to be trimmed
Packit Service 0210bb
 */
Packit Service 0210bb
void p11_attribute_trim(CK_ATTRIBUTE *attr);
Packit Service 0210bb
Packit Service 0210bb
#endif                          // #ifndef _P11UTIL_H_