Google Cloud IoT device SDK for embedded C  1.0.2
iotc_jwt.h
Go to the documentation of this file.
1 /* Copyright 2018-2020 Google LLC
2  *
3  * This is part of the Google Cloud IoT Device SDK for Embedded C.
4  * It is licensed under the BSD 3-Clause license; you may not use this file
5  * except in compliance with the License.
6  *
7  * You may obtain a copy of the License at:
8  * https://opensource.org/licenses/BSD-3-Clause
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __IOTC_JWT_H__
18 #define __IOTC_JWT_H__
19 
20 #include <iotc_types.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
31 #define IOTC_JWT_HEADER_BUF_SIZE 40
32 
33 #define IOTC_JWT_HEADER_BUF_SIZE_BASE64 \
34  (((IOTC_JWT_HEADER_BUF_SIZE + 2) / 3) * 4)
35 
37 #define IOTC_JWT_PAYLOAD_BUF_SIZE 256
38 
39 #define IOTC_JWT_PAYLOAD_BUF_SIZE_BASE64 \
40  (((IOTC_JWT_PAYLOAD_BUF_SIZE + 2) / 3) * 4)
41 
43 #define IOTC_JWT_MAX_SIGNATURE_SIZE 132
44 
45 #define IOTC_JWT_MAX_SIGNATURE_SIZE_BASE64 \
46  (((IOTC_JWT_MAX_SIGNATURE_SIZE + 2) / 3) * 4)
47 
49 #define IOTC_JWT_SIZE \
50  (IOTC_JWT_HEADER_BUF_SIZE_BASE64 + 1 + IOTC_JWT_PAYLOAD_BUF_SIZE_BASE64 + \
51  1 + IOTC_JWT_MAX_SIGNATURE_SIZE_BASE64)
52 
68  const char* project_id, uint32_t expiration_period_sec,
69  const iotc_crypto_key_data_t* private_key_data, char* dst_jwt_buf,
70  size_t dst_jwt_buf_len, size_t* bytes_written);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* __IOTC_JWT_H__ */
The parameters with which to create JWTs.
Definition: iotc_types.h:260
iotc_state_t
The state of the client application.
Definition: iotc_error.h:32
Defines custom data formats.
iotc_state_t iotc_create_iotcore_jwt(const char *project_id, uint32_t expiration_period_sec, const iotc_crypto_key_data_t *private_key_data, char *dst_jwt_buf, size_t dst_jwt_buf_len, size_t *bytes_written)
Creates a JWT for authenticating to Cloud IoT Core.