⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prikeyder.h

📁 IBE是一种非对称密码技术
💻 H
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
 */

#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "derhelp.h"
#include "oidlist.h"
#include "algid.h"

#ifndef _PRI_KEY_DER_H
#define _PRI_KEY_DER_H

#ifdef __cplusplus
extern "C" {
#endif

/* A PKCS #8 PrivateKeyInfo is
 *    SEQUENCE {
 *      version         INTEGER { v1(0) },
 *      priKeyAlg       AlgorithmIdentifier
 *      privateKey      OCTET STRING
 *      attributes  [0] Attributes OPTIONAL }
 */

/* The OpenSSL template definitions.
 */
typedef struct
{
  ASN1_INTEGER *version;
  Asn1AlgorithmId *algId;
  ASN1_OCTET_STRING *encodedKey;
  Asn1Encoded *attributes;
} Asn1PrivateKeyInfo;

DECLARE_ASN1_FUNCTIONS (Asn1PrivateKeyInfo)

/* Create a PrivateKeyInfo encoding.
 *    SEQUENCE {
 *      version         INTEGER { v1(0) },
 *      priKeyAlg       AlgorithmIdentifier
 *      privateKey      OCTET STRING
 *      attributes  [0] Attributes OPTIONAL }
 * <p>This implementation will not encode attributes.
 * <p>The routine will deposit the result into the caller-supplied
 * buffer (of size bufferSize bytes). It will then go to the address
 * given by encodedKeyLen and deposit the length of the result string.
 * If the result buffer is not big enough, the routine will return the
 * "BufferTooSmall" error and set the encodedKeyLen value to the
 * required space.
 * <p>This function does no argument checking, it is the responsibility
 * of the caller not to make mistakes.
 *
 * @param libCtx The library context to use.
 * @param oid For the algID.
 * @param oidLen The length, in bytes, of the oid.
 * @param params The params for the algID already encoded.
 * @param paramsLen The length, in bytes of the encoded params.
 * @param encodedKey The private key data, already encoded, to be
 * wrapped by the OCTET STRING.
 * @param encodedKeyLen The length, in bytes, of the encodedKey.
 * @param keyDer The buffer into which this function will place the DER
 * of the key.
 * @param bufferSize The size, in bytes, of the output buffer.
 * @param keyDerLen The address where this function will deposit the
 * length of the encoding of the PrivateKeyInfo, the number of bytes
 * placed into the buffer.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
int VOLT_CALLING_CONV VoltEncodePrivateKeyInfoDer VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   unsigned char *oid,
   unsigned int oidLen,
   unsigned char *params,
   unsigned int paramsLen,
   unsigned char *encodedKey,
   unsigned int encodedKeyLen,
   unsigned char *keyDer,
   unsigned int bufferSize,
   unsigned int *keyDerLen
));

/* Decode PrivateKeyInfo. This function creates a new Asn1PrivateKeyInfo
 * "object", it is the responsibility of the caller to destroy it (by
 * calling Asn1PrivateKeyInfo_free).
 * <p>If the encoding is not PrivateKeyInfo, this function returns the
 * error VT_ERROR_UNKNOWN_BER.
 *
 * @param libCtx The library context to use.
 * @param encoding The buffer containing the alleged PrivateKeyInfo.
 * @param maxEncodingLen The max number of bytes to decode.
 * @param priKeyInfo The address where this function will deposit the
 * created Asn1PrivateKeyInfo "object".
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
int VOLT_CALLING_CONV VoltDecodePriKeyInfoCreate VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   unsigned char *encoding,
   unsigned int maxEncodingLen,
   Asn1PrivateKeyInfo **priKeyInfo
));

#ifdef __cplusplus
}
#endif

#endif /* _PRI_KEY_DER_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -