Skip to content

Commit

Permalink
Compatibility with QCBOR v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Lundblade committed Jan 5, 2025
1 parent cdd4edd commit 008add0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
project(t_cose
DESCRIPTION "t_cose"
LANGUAGES C
VERSION 1.0.1)
VERSION 1.1.3)

# Constants
set(CRYPTO_PROVIDERS "OpenSSL" "MbedTLS" "Test")
Expand Down
4 changes: 2 additions & 2 deletions Makefile.ossl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ TEST_OBJ=test/t_cose_test.o test/run_tests.o test/t_cose_sign_verify_test.o test


# ---- the main body that is invariant ----
INC=-I inc -I test -I src
ALL_INC=$(INC) $(CRYPTO_INC) $(QCBOR_INC)
T_COSE_INC=-I inc -I test -I src
ALL_INC=$(T_COSE_INC) $(QCBOR_INC) $(CRYPTO_INC)
CFLAGS=$(CMD_LINE) $(ALL_INC) $(C_OPTS) $(TEST_CONFIG_OPTS) $(CRYPTO_CONFIG_OPTS)

SRC_OBJ=src/t_cose_sign1_verify.o src/t_cose_sign1_sign.o src/t_cose_util.o src/t_cose_parameters.o src/t_cose_short_circuit.o
Expand Down
4 changes: 2 additions & 2 deletions Makefile.psa
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ TEST_OBJ=test/t_cose_test.o test/run_tests.o test/t_cose_sign_verify_test.o test


# ---- the main body that is invariant ----
INC=-I inc -I test -I src
ALL_INC=$(INC) $(CRYPTO_INC) $(QCBOR_INC)
T_COSE_INC=-I inc -I test -I src
ALL_INC=$(T_COSE_INC) $(QCBOR_INC) $(CRYPTO_INC)
CFLAGS=$(CMD_LINE) $(ALL_INC) $(C_OPTS) $(TEST_CONFIG_OPTS) $(CRYPTO_CONFIG_OPTS)

SRC_OBJ=src/t_cose_sign1_verify.o src/t_cose_sign1_sign.o src/t_cose_util.o src/t_cose_parameters.o src/t_cose_short_circuit.o
Expand Down
10 changes: 6 additions & 4 deletions Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

# ---- QCBOR location ----
# Adjust this to the location of QCBOR in your build environment
#QCBOR_INC= -I ../../QCBOR/master/inc
#QCBOR_LIB=../../QCBOR/master/libqcbor.a
#QCBOR_DIR=../../QCBOR/master
#QCBOR_INC=-I $(QCBOR_DIR)/inc
#QCBOR_LIB=$(QCBOR_DIR)/libqcbor.a

QCBOR_INC= -I/usr/include -I/usr/local/include
QCBOR_LIB= -l qcbor

Expand All @@ -42,8 +44,8 @@ TEST_OBJ=test/t_cose_test.o test/run_tests.o test/t_cose_make_test_messages.o $(


# ---- the main body that is invariant ----
INC=-I inc -I test -I src
ALL_INC=$(INC) $(CRYPTO_INC) $(QCBOR_INC)
T_COSE_INC=-I inc -I test -I src
ALL_INC=$(T_COSE_INC) $(QCBOR_INC) $(CRYPTO_INC)
CFLAGS=$(CMD_LINE) $(ALL_INC) $(C_OPTS) $(TEST_CONFIG_OPTS) $(CRYPTO_CONFIG_OPTS)

SRC_OBJ=src/t_cose_sign1_verify.o src/t_cose_sign1_sign.o src/t_cose_util.o src/t_cose_parameters.o src/t_cose_short_circuit.o
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ useful for embedded implementations that have to run in small fixed memory.

## Documentation

[API documentation is here](https://laurencelundblade.github.io/t_cose/)
[API documentation is here](https://www.securitytheory.com/t_cose-docs)


## Code Status
Expand Down Expand Up @@ -70,6 +70,9 @@ If QCBOR is installed in /usr/local, then the makefiles should find
it. If not then QCBOR may need to be downloaded. The makefiles can be
modified to reference it other than in /usr/local.

This works with both QCBOR v1 and v2. When running with v2 it
uses the QCBOR v1 compatibility mode for tag decoding.

### Supported Cryptographic Libraries

Here's three crypto library configurations that are supported. Others
Expand Down
2 changes: 1 addition & 1 deletion inc/t_cose/t_cose_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extern "C" {
*/
#define T_COSE_VERSION_MAJOR 1
#define T_COSE_VERSION_MINOR 1
#define T_COSE_VERSION_PATCH 2
#define T_COSE_VERSION_PATCH 3


/**
Expand Down
7 changes: 6 additions & 1 deletion src/t_cose_sign1_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,14 @@ t_cose_sign1_verify_internal(struct t_cose_sign1_verify_ctx *me,
clear_label_list(&critical_parameter_labels);
clear_cose_parameters(&parameters);

#if QCBOR_VERSION_MAJOR >= 2
const int decode_config = QCBOR_DECODE_ALLOW_UNPROCESSED_TAG_NUMBERS;
#else
const int decode_config = QCBOR_DECODE_MODE_NORMAL;
#endif

/* === Decoding of the array of four starts here === */
QCBORDecode_Init(&decode_context, cose_sign1, QCBOR_DECODE_MODE_NORMAL);
QCBORDecode_Init(&decode_context, cose_sign1, decode_config);

/* --- The array of 4 and tags --- */
QCBORDecode_EnterArray(&decode_context, NULL);
Expand Down
4 changes: 2 additions & 2 deletions t_cose.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = NO;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
Expand Down Expand Up @@ -878,7 +878,7 @@
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = NO;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
Expand Down

0 comments on commit 008add0

Please sign in to comment.