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

📄 pubkeyder.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 _PUB_KEY_DER_H
#define _PUB_KEY_DER_H

#ifdef __cplusplus
extern "C" {
#endif

/* An X.509 SubjectPublicKeyInfo is
 *    SEQUENCE {
 *      algorithm          AlgorithmIdentifier,
 *      subjectPublicKey   BIT STRING }
 */

/* The OpenSSL template definitions.
 */
typedef struct
{
  Asn1AlgorithmId *algId;
  ASN1_BIT_STRING *encodedKey;
} Asn1SubjectPublicKey;

DECLARE_ASN1_FUNCTIONS (Asn1SubjectPublicKey)

/* Create a SubjectPublicKey encoding.
 *    SEQUENCE {
 *      pubKeyAlg       AlgorithmIdentifier,
 *      publicKey       BIT STRING }
 * <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 public key data, already encoded, to be
 * wrapped by the BIT 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 SubjectPublicKey, 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 VoltEncodeSubjectPublicKeyDer 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 SubjectPublicKey. This function creates a new
 * Asn1SubjectPublicKey "object", it is the responsibility of the
 * caller to destroy it (by calling Asn1SubjectPublicKey_free).
 * <p>If the encoding is not SubjectPublicKey, this function returns
 * the error VT_ERROR_UNKNOWN_BER.
 *
 * @param libCtx The library context to use.
 * @param encoding The buffer containing the alleged SubjectPublicKey.
 * @param maxEncodingLen The max number of bytes to decode.
 * @param priKeyInfo The address where this function will deposit the
 * created Asn1SubjectPublicKey "object".
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
int VOLT_CALLING_CONV VoltDecodeSubjPubKeyCreate VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   unsigned char *encoding,
   unsigned int maxEncodingLen,
   Asn1SubjectPublicKey **subjPubKey
));

#ifdef __cplusplus
}
#endif

#endif /* _PUB_KEY_DER_H */

⌨️ 快捷键说明

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