API参考
载入中...
搜索中...
未找到
privpass_token.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
16#ifndef PRIVPASS_TOKEN_H
17#define PRIVPASS_TOKEN_H
18
19#include <stdint.h>
20#include "bsl_types.h"
21#include "bsl_params.h"
22#include "auth_params.h"
23#include "auth_privpass_token.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/* Constants for Private Pass Token */
30#define PRIVPASS_PUBLIC_VERIFY_TOKENTYPE ((uint16_t)0x0002)
31#define PRIVPASS_TOKEN_NK 256 // RSA-2048 key size in bytes
32#define PRIVPASS_TOKEN_SHA256_SIZE 32 // SHA256 hash size in bytes
33#define PRIVPASS_TOKEN_NONCE_LEN 32 // Random nonce length
34#define PRIVPASS_MAX_ISSUER_NAME_LEN 65535
35#define PRIVPASS_REDEMPTION_LEN 32
36#define PRIVPASS_MAX_ORIGIN_INFO_LEN 65535
37
38// 2(tokenType) + 32(nonce) + 32(challengeDigest) + 32(tokenKeyId)
39#define HITLS_AUTH_PRIVPASS_TOKEN_INPUT_LEN (2 + 32 + 32 + 32)
40
41/* Structure for token challenge request */
42typedef struct {
43 uint8_t *challengeReq; // Challenge request data
44 uint32_t challengeReqLen; // Length of challenge request
46
47/* Structure for token challenge from server */
48typedef struct {
49 uint16_t tokenType; // Token type (e.g., Blind RSA 2048-bit)
50 BSL_Buffer issuerName; // Name of the token issuer
51 BSL_Buffer redemption; // Redemption information
52 BSL_Buffer originInfo; // Origin information
54
55typedef struct {
56 uint16_t tokenType;
57 uint8_t truncatedTokenKeyId;
58 BSL_Buffer blindedMsg;
60
61typedef struct {
62 uint8_t *blindSig;
63 uint32_t blindSigLen;
65
66typedef enum {
67 HITLS_AUTH_PRIVPASS_TOKEN_RESPONSE_PUB = 1,
68} PrivPass_TokenResponseType;
69
70typedef struct {
71 int32_t type;
72 union {
74 } st;
76
77typedef struct {
78 uint16_t tokenType;
79 uint8_t nonce[PRIVPASS_TOKEN_NONCE_LEN];
80 uint8_t challengeDigest[PRIVPASS_TOKEN_SHA256_SIZE];
81 uint8_t tokenKeyId[PRIVPASS_TOKEN_SHA256_SIZE];
82 BSL_Buffer authenticator;
84
86 int32_t type;
87 union {
88 PrivPass_TokenChallengeReq *tokenChallengeReq;
89 PrivPass_TokenChallenge *tokenChallenge;
90 PrivPass_TokenRequest *tokenRequest;
91 PrivPass_TokenResponse *tokenResponse;
93 } st;
94};
95
109
110/* Main context structure for Private Pass operations */
112 void *prvKeyCtx; // Private key context
113 void *pubKeyCtx; // Public key context
114 uint8_t tokenKeyId[PRIVPASS_TOKEN_SHA256_SIZE]; // Token key identifier
115 uint8_t nonce[PRIVPASS_TOKEN_NONCE_LEN]; // Random nonce
116 PrivPassCryptCb method; // Cryptographic callbacks
117};
118
123PrivPassCryptCb PrivPassCryptPubCb(void);
124
125#ifdef __cplusplus
126}
127#endif
128
129#endif // PRIVPASS_TOKEN_H
Parameter identifiers for authentication control-style APIs.
int32_t(* HITLS_AUTH_PrivPassCheckKeyPair)(void *pubKeyCtx, void *prvKeyCtx)
Verifies that a public/private key pair matches.
定义 auth_privpass_token.h:248
int32_t(* HITLS_AUTH_PrivPassDecodePrvKey)(void *libCtx, const char *attrName, void *param, uint8_t *prvKey, uint32_t prvKeyLen, void **pkeyCtx)
Decodes a private key and gen a key ctx. The default algorithm callback implementation is supported o...
定义 auth_privpass_token.h:235
void(* HITLS_AUTH_PrivPassFreePkeyCtx)(void *pkeyCtx)
Frees a previously allocated key context.
定义 auth_privpass_token.h:116
int32_t(* HITLS_AUTH_PrivPassBlind)(void *pkeyCtx, int32_t algId, const uint8_t *data, uint32_t dataLen, uint8_t *blindedData, uint32_t *blindedDataLen)
Blinds data using the key context and hash algorithm for blind signature protocol....
定义 auth_privpass_token.h:150
int32_t(* HITLS_AUTH_PrivPassVerify)(void *pkeyCtx, int32_t algId, const uint8_t *data, uint32_t dataLen, const uint8_t *sign, uint32_t signLen)
Verifies a signature using the public key context.
定义 auth_privpass_token.h:200
void *(* HITLS_AUTH_PrivPassNewPkeyCtx)(void *libCtx, const char *attrName, int32_t algId)
Creates a new public/private key context for the specified algorithm.
定义 auth_privpass_token.h:108
int32_t(* HITLS_AUTH_PrivPassDecodePubKey)(void *libCtx, const char *attrName, uint8_t *pubKey, uint32_t pubKeyLen, void **pkeyCtx)
Decodes a public key and gen a key ctx. The default algorithm callback implementation is supported on...
定义 auth_privpass_token.h:217
int32_t(* HITLS_AUTH_PrivPassRandom)(uint8_t *buffer, uint32_t bufferLen)
Generates random bytes.
定义 auth_privpass_token.h:260
int32_t(* HITLS_AUTH_PrivPassDigest)(void *libCtx, const char *attrName, int32_t algId, const uint8_t *input, uint32_t inputLen, uint8_t *digest, uint32_t *digestLen)
Computes a cryptographic digest of the input data.
定义 auth_privpass_token.h:132
int32_t(* HITLS_AUTH_PrivPassUnblind)(void *pkeyCtx, const uint8_t *blindedData, uint32_t blindedDataLen, uint8_t *data, uint32_t *dataLen)
Unblinds previously blinded data to reveal the actual signature. The default algorithm callback imple...
定义 auth_privpass_token.h:167
int32_t(* HITLS_AUTH_PrivPassSignData)(void *pkeyCtx, const uint8_t *data, uint32_t dataLen, uint8_t *sign, uint32_t *signLen)
Signs data using the private key context.
定义 auth_privpass_token.h:183
定义 bsl_types.h:40
定义 privpass_token.h:96
定义 privpass_token.h:111
定义 privpass_token.h:42
定义 privpass_token.h:48
定义 privpass_token.h:77
定义 privpass_token.h:61
定义 privpass_token.h:55
定义 privpass_token.h:70
定义 privpass_token.h:85