aboutsummaryrefslogtreecommitdiffstats
path: root/library/c/tvmauth/deprecated.h
blob: f2e9e843cf4f83379c4c4c9ec3103dbda3f878df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#pragma once
// DO_NOT_STYLE

#ifndef _TVM_AUTH_DEPRECATED_H_
#define _TVM_AUTH_DEPRECATED_H_

#include "tvmauth.h"

#ifdef __cplusplus
extern "C" {
#endif

/*!
 * Please do not use thees types: use TvmClient instead
 */

struct TA_TServiceContext;
struct TA_TUserContext;

/*!
 * Create service context. Serivce contexts are used to store TVM keys and parse service tickets.
 * @param[in] tvmId Can be 0 if tvmKeysResponse == NULL
 * @param[in] secretBase64 Secret, can be NULL if param 'tvmKeysResponse' is not NULL. Sign attempt hence raises exception
 * @param[in] secretBase64Size Size of string containing secret
 * @param[in] tvmKeysResponse TVM Keys gotten from TVM API, can be NULL if param 'secretBase64' is not NULL. Only for ticket checking
 * @param[in] tvmKeysResponseSize Size of string containing keys
 * @param[out] context
 * @return Error code
 */
enum TA_EErrorCode TA_CreateServiceContext(
    uint32_t tvmId,
    const char* secretBase64,
    size_t secretBase64Size,
    const char* tvmKeysResponse,
    size_t tvmKeysResponseSize,
    struct TA_TServiceContext** context);

/*!
 * Free memory of service context.
 * @param[in] context
 * @return Error code
 */
enum TA_EErrorCode TA_DeleteServiceContext(struct TA_TServiceContext* context);

/*!
 * Parse and validate service ticket body then create TCheckedServiceTicket object.
 * @param[in] context
 * @param[in] ticketBody Service ticket body as string
 * @param[in] ticketBodySize Size of string containing service ticket body
 * @param[out] ticket Service ticket object
 * @return Error code
 */
enum TA_EErrorCode TA_CheckServiceTicket(
    const struct TA_TServiceContext* context,
    const char* ticketBody,
    size_t ticketBodySize,
    struct TA_TCheckedServiceTicket** ticket);

/*!
 * Create signature for selected parameters. Allocate at least 512 byte for signature buffer.
 * @param[in] context
 * @param[in] ts Param 'ts' of request to TVM
 * @param[in] tsSize Size of param 'ts' of request to TVM
 * @param[in] dst Param 'dst' of request to TVM
 * @param[in] dstSize Size of param 'dst' of request to TVM
 * @param[in] scopes Param 'scopes' of request to TVM
 * @param[in] scopesSize Size of param 'scopes' of request to TVM
 * @param[out] signature
 * @param[out] signatureSize
 * @param[in] maxSignatureSize
 * @return Error code
 */
enum TA_EErrorCode TA_SignCgiParamsForTvm(
    const struct TA_TServiceContext* context,
    const char* ts,
    size_t tsSize,
    const char* dst,
    size_t dstSize,
    const char* scopes,
    size_t scopesSize,
    char* signature,
    size_t* signatureSize,
    size_t maxSignatureSize);

/*!
 * Create user context. User contexts are used to store TVM keys and parse user tickets.
 * @param[in] env
 * @param[in] tvmKeysResponse
 * @param[in] tvmKeysResponseSize
 * @param[out] context
 * @return Error code
 */
enum TA_EErrorCode TA_CreateUserContext(
    enum TA_EBlackboxEnv env,
    const char* tvmKeysResponse,
    size_t tvmKeysResponseSize,
    struct TA_TUserContext** context);

/*!
 * Free memory of user context.
 * @param[in] context
 * @return Error code
 */
enum TA_EErrorCode TA_DeleteUserContext(struct TA_TUserContext* context);

/*!
 * Parse and validate user ticket body then create TCheckedUserTicket object.
 * @param[in] context
 * @param[in] ticketBody Service ticket body as string
 * @param[in] ticketBodySize Size of string containing service ticket body
 * @param[out] ticket Service ticket object
 * @return Error code
 */
enum TA_EErrorCode TA_CheckUserTicket(
    const struct TA_TUserContext* context,
    const char* ticketBody,
    size_t ticketBodySize,
    struct TA_TCheckedUserTicket** ticket);

#ifdef __cplusplus
}
#endif
#endif