NZCP.c  0.0.5
An implementation of the New Zealand COVID Pass specification in C
nzcp.h
1 /* Copyright (C) 1991-2020 Free Software Foundation, Inc.
2  This file is part of the GNU C Library.
3 
4  The GNU C Library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  The GNU C Library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with the GNU C Library; if not, see
16  <https://www.gnu.org/licenses/>. */
17 /* This header is separate from features.h so that the compiler can
18  include it implicitly at the start of every compilation. It must
19  not itself include <features.h> or any other header that includes
20  <features.h> because the implicit include comes before any feature
21  test macros that may be defined in a source file before it first
22  explicitly includes a system header. GCC knows the name of this
23  header in order to preinclude it. */
24 /* glibc's intent is to support the IEC 559 math functionality, real
25  and complex. If the GCC (4.9 and later) predefined macros
26  specifying compiler intent are available, use them to determine
27  whether the overall intent is to support these features; otherwise,
28  presume an older compiler has intent to support these features and
29  define these macros by default. */
30 /* wchar_t uses Unicode 10.0.0. Version 10.0 of the Unicode Standard is
31  synchronized with ISO/IEC 10646:2017, fifth edition, plus
32  the following additions from Amendment 1 to the fifth edition:
33  - 56 emoji characters
34  - 285 hentaigana
35  - 3 additional Zanabazar Square characters */
36 #ifndef __NZCP_H_
37 #define __NZCP_H_
38 #include <stdlib.h>
39 #include <stdint.h>
40 #include <stdbool.h>
41 #define NZCP_VERSION_MAJOR 0
42 #define NZCP_VERSION_MINOR 0
43 #define NZCP_VERSION_PATCH 5
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
55 typedef struct nzcp_verification_result { char* jti; char* iss; int nbf; int exp; char* given_name; char* family_name; char* dob;
144 } nzcp_error;
153 nzcp_error nzcp_verify_pass_uri(uint8_t* pass_uri, nzcp_verification_result* verification_result, bool is_example);
167 const char* nzcp_error_string(nzcp_error error);
169 #ifdef __cplusplus
170 }
171 #endif
172 #endif
NZCP_E_BAD_VC_CONTEXT
@ NZCP_E_BAD_VC_CONTEXT
Definition: nzcp.h:136
NZCP_E_EMPTY_URI
@ NZCP_E_EMPTY_URI
Definition: nzcp.h:107
NZCP_E_MALFORMED_CREDENTIAL_SUBJECT
@ NZCP_E_MALFORMED_CREDENTIAL_SUBJECT
Definition: nzcp.h:125
NZCP_E_BAD_ISS
@ NZCP_E_BAD_ISS
Definition: nzcp.h:131
NZCP_E_MALFORMED_CWT
@ NZCP_E_MALFORMED_CWT
Definition: nzcp.h:112
NZCP_E_BAD_VERSION_IDENTIFIER
@ NZCP_E_BAD_VERSION_IDENTIFIER
Definition: nzcp.h:109
nzcp_verification_result::family_name
char * family_name
Definition: nzcp.h:61
nzcp_error
nzcp_error
The nzcp_error enum used for verfication errors.
Definition: nzcp.h:105
NZCP_E_BAD_VC_TYPE
@ NZCP_E_BAD_VC_TYPE
Definition: nzcp.h:137
NZCP_E_BAD_NBF
@ NZCP_E_BAD_NBF
Definition: nzcp.h:132
nzcp_verification_result::exp
int exp
Definition: nzcp.h:59
NZCP_E_MALFORMED_VC_VERSION
@ NZCP_E_MALFORMED_VC_VERSION
Definition: nzcp.h:123
NZCP_E_BAD_VC_VERSION
@ NZCP_E_BAD_VC_VERSION
Definition: nzcp.h:138
NZCP_E_SUCCESS
@ NZCP_E_SUCCESS
Definition: nzcp.h:106
NZCP_E_MALFORMED_GIVEN_NAME
@ NZCP_E_MALFORMED_GIVEN_NAME
Definition: nzcp.h:126
nzcp_verification_result::iss
char * iss
Definition: nzcp.h:57
NZCP_E_UNKNOWN
@ NZCP_E_UNKNOWN
Definition: nzcp.h:142
NZCP_E_MALFORMED_CWT_CLAIMS
@ NZCP_E_MALFORMED_CWT_CLAIMS
Definition: nzcp.h:116
NZCP_E_MALFORMED_DOB
@ NZCP_E_MALFORMED_DOB
Definition: nzcp.h:128
NZCP_E_MALFORMED_CWT_NBF
@ NZCP_E_MALFORMED_CWT_NBF
Definition: nzcp.h:118
NZCP_E_MALFORMED_CWT_CTI
@ NZCP_E_MALFORMED_CWT_CTI
Definition: nzcp.h:120
NZCP_E_FAILED_SIGNATURE_VERIFICATION
@ NZCP_E_FAILED_SIGNATURE_VERIFICATION
Definition: nzcp.h:141
NZCP_E_MALFORMED_CWT_EXP
@ NZCP_E_MALFORMED_CWT_EXP
Definition: nzcp.h:119
NZCP_E_PASS_NOT_ACTIVE
@ NZCP_E_PASS_NOT_ACTIVE
Definition: nzcp.h:134
nzcp_verification_result::given_name
char * given_name
Definition: nzcp.h:60
NZCP_E_BAD_DOB
@ NZCP_E_BAD_DOB
Definition: nzcp.h:140
NZCP_E_BAD_CTI
@ NZCP_E_BAD_CTI
Definition: nzcp.h:130
NZCP_E_BAD_INTEGRATION
@ NZCP_E_BAD_INTEGRATION
Definition: nzcp.h:143
NZCP_E_WRONG_KID
@ NZCP_E_WRONG_KID
Definition: nzcp.h:114
NZCP_E_WRONG_ALG
@ NZCP_E_WRONG_ALG
Definition: nzcp.h:115
NZCP_E_WRONG_TRUSTED_ISSUER
@ NZCP_E_WRONG_TRUSTED_ISSUER
Definition: nzcp.h:129
nzcp_verification_result::jti
char * jti
Definition: nzcp.h:56
NZCP_E_MALFORMED_CWT_VC
@ NZCP_E_MALFORMED_CWT_VC
Definition: nzcp.h:121
NZCP_E_MALFORMED_VC_CONTEXT
@ NZCP_E_MALFORMED_VC_CONTEXT
Definition: nzcp.h:122
NZCP_E_PASS_EXPIRED
@ NZCP_E_PASS_EXPIRED
Definition: nzcp.h:135
nzcp_error_string
const char * nzcp_error_string(nzcp_error error)
Returns the error description for the given error code.
NZCP_E_CBOR_ERROR
@ NZCP_E_CBOR_ERROR
Definition: nzcp.h:110
NZCP_E_BAD_URI_PREFIX
@ NZCP_E_BAD_URI_PREFIX
Definition: nzcp.h:108
nzcp_verification_result::nbf
int nbf
Definition: nzcp.h:58
nzcp_verification_result
The nzcp_verification_result structure.
Definition: nzcp.h:55
NZCP_E_BAD_TAG
@ NZCP_E_BAD_TAG
Definition: nzcp.h:111
NZCP_E_BAD_EXP
@ NZCP_E_BAD_EXP
Definition: nzcp.h:133
NZCP_E_MALFORMED_CWT_HEADER
@ NZCP_E_MALFORMED_CWT_HEADER
Definition: nzcp.h:113
NZCP_E_MALFORMED_FAMILY_NAME
@ NZCP_E_MALFORMED_FAMILY_NAME
Definition: nzcp.h:127
nzcp_verification_result::dob
char * dob
Definition: nzcp.h:62
nzcp_free_verification_result
void nzcp_free_verification_result(nzcp_verification_result *verification_result)
Frees nzcp_verification_result struct. Run this after you're done with the result.
NZCP_E_MALFORMED_CWT_ISSUER
@ NZCP_E_MALFORMED_CWT_ISSUER
Definition: nzcp.h:117
NZCP_E_MALFORMED_VC_TYPE
@ NZCP_E_MALFORMED_VC_TYPE
Definition: nzcp.h:124
NZCP_E_BAD_GIVEN_NAME
@ NZCP_E_BAD_GIVEN_NAME
Definition: nzcp.h:139
nzcp_verify_pass_uri
nzcp_error nzcp_verify_pass_uri(uint8_t *pass_uri, nzcp_verification_result *verification_result, bool is_example)
Verifies New Zealand COVID Pass URI.