Skip to content

Commit

Permalink
New COSE-HPKE Implementation Attempt
Browse files Browse the repository at this point in the history
Focusing on <draft-ietf-cose-hpke-07> in preparation for interoperability testing.
  • Loading branch information
hannestschofenig committed Jan 28, 2024
1 parent 1eeef3b commit 1f4ed74
Show file tree
Hide file tree
Showing 21 changed files with 3,550 additions and 29 deletions.
48 changes: 45 additions & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ SRC_OBJ=src/t_cose_util.o \
src/t_cose_encrypt_dec.o \
src/t_cose_recipient_dec_keywrap.o \
src/t_cose_recipient_enc_keywrap.o \
src/t_cose_recipient_dec_hpke.o \
src/t_cose_recipient_enc_hpke.o \
src/t_cose_recipient_dec_esdh.o \
src/t_cose_recipient_enc_esdh.o \
src/hpke.o \
src/t_cose_qcbor_gap.o


Expand All @@ -58,6 +61,10 @@ EXAMPLE_OBJ=examples/examples_main.o \
examples/example_keys.o \
examples/print_buf.o

# ---- Object files for hpke_test ----
HPKE_TEST_OBJ=examples/hpke_test.o \
examples/example_keys.o \
examples/print_buf.o

# ---- public headers -----
PUBLIC_INTERFACE=inc/t_cose/q_useful_buf.h \
Expand All @@ -70,8 +77,10 @@ PUBLIC_INTERFACE=inc/t_cose/q_useful_buf.h \
inc/t_cose/t_cose_parameters.h \
inc/t_cose/t_cose_recipient_dec.h \
inc/t_cose/t_cose_recipient_dec_keywrap.h \
inc/t_cose/t_cose_recipient_dec_hpke.h \
inc/t_cose/t_cose_recipient_enc.h \
inc/t_cose/t_cose_recipient_enc_keywrap.h \
inc/t_cose/t_cose_recipient_enc_hpke.h \
inc/t_cose/t_cose_recipient_dec_esdh.h \
inc/t_cose/t_cose_recipient_enc.h \
inc/t_cose/t_cose_recipient_enc_keywrap.h \
Expand Down Expand Up @@ -193,7 +202,7 @@ src/t_cose_recipient_enc_keywrap.o: src/t_cose_recipient_enc_keywrap.c
src/t_cose_recipient_dec_keywrap.o: src/t_cose_recipient_dec_keywrap.c


src/t_cose_recpient_enc_esdh.o: src/t_cose_recipient_enc_esdh.c \
src/t_cose_recipient_enc_esdh.o: src/t_cose_recipient_enc_esdh.c \
inc/t_cose/t_cose_standard_constants.h \
inc/t_cose/t_cose_key.h \
inc/t_cose/t_cose_encrypt_enc.h \
Expand All @@ -203,9 +212,9 @@ src/t_cose_recpient_enc_esdh.o: src/t_cose_recipient_enc_esdh.c \
inc/t_cose/t_cose_recipient_enc_keywrap.h \
inc/t_cose/q_useful_buf.h \
src/t_cose_crypto.h \
src/t_cose_util.h \
src/t_cose_util.h

src/t_cose_recpient_dec_esdh.o: src/t_cose_recipient_dec_esdh.c \
src/t_cose_recipient_dec_esdh.o: src/t_cose_recipient_dec_esdh.c \
inc/t_cose/t_cose_recipient_dec_esdh.h \
inc/t_cose/t_cose_parameters.h \
inc/t_cose/q_useful_buf.h \
Expand All @@ -218,6 +227,33 @@ src/t_cose_recpient_dec_esdh.o: src/t_cose_recipient_dec_esdh.c \
src/t_cose_crypto.h \
src/t_cose_util.h

src/t_cose_recipient_enc_hpke.o: src/t_cose_recipient_enc_hpke.c \
src/hpke.h \
inc/t_cose/t_cose_standard_constants.h \
inc/t_cose/t_cose_key.h \
inc/t_cose/t_cose_encrypt_enc.h \
inc/t_cose/t_cose_recipient_enc.h \
inc/t_cose/t_cose_common.h \
inc/t_cose/t_cose_parameters.h \
inc/t_cose/t_cose_recipient_enc_keywrap.h \
inc/t_cose/q_useful_buf.h \
src/t_cose_crypto.h \
src/t_cose_util.h

src/t_cose_recipient_dec_hpke.o: src/t_cose_recipient_dec_hpke.c \
src/hpke.h \
inc/t_cose/t_cose_recipient_dec_hpke.h \
inc/t_cose/t_cose_parameters.h \
inc/t_cose/q_useful_buf.h \
inc/t_cose/t_cose_common.h \
inc/t_cose/t_cose_standard_constants.h \
inc/t_cose/t_cose_recipient_dec.h \
inc/t_cose/t_cose_key.h \
inc/t_cose/t_cose_encrypt_enc.h \
inc/t_cose/t_cose_recipient_enc.h \
src/t_cose_crypto.h \
src/t_cose_util.h

# ---- test dependencies -----
test/t_cose_test.o: test/t_cose_test.h \
test/t_cose_make_test_messages.h \
Expand Down Expand Up @@ -257,6 +293,12 @@ examples/encryption_examples.o: examples/encryption_examples.h \
examples/init_keys.h \
examples/print_buf.h


examples/hpke_test.o: examples/hpke_test.c \
$(PUBLIC_INTERFACE) \
examples/init_keys.h \
examples/print_buf.h

examples/signing_examples.o: examples/signing_examples.h \
examples/signing_examples.c \
examples/init_keys.h \
Expand Down
4 changes: 2 additions & 2 deletions Makefile.ossl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ CRYPTO_EXAMPLE_OBJ=examples/init_keys_ossl.o
# ---- other configuration ----
# Use as needed. It has been used to disable features that aren't ready
# or that aren't passing tests
OTHER_OPTS=

# OTHER_OPTS=
OTHER_OPTS=-DT_COSE_DISABLE_HPKE

# ---- compiler configuration -----
# This makefile uses a minimum of compiler flags so that it will
Expand Down
27 changes: 15 additions & 12 deletions Makefile.psa
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,28 @@
# This is for direct reference to QCBOR that is not installed in
# /usr/local or some system location. The path may need to be adjusted
# for your location of QCBOR.
#QCBOR_DIR=../../QCBOR/master
#QCBOR_INC=-I $(QCBOR_DIR)/inc
#QCBOR_LIB=$(QCBOR_DIR)/libqcbor.a
QCBOR_INC=-I ../QCBOR/inc
QCBOR_LIB=../QCBOR/build/libqcbor.a -lm

# This is for reference to QCBOR that is installed in /usr/local or in
# some system location. This will typically use dynamic linking if
# there is a libqcbor.so
QCBOR_INC=-I /usr/local/include
QCBOR_LIB=-lqcbor

#QCBOR_INC=-I /usr/local/include
#QCBOR_LIB=-lqcbor

# ---- crypto configuration -----

# These two are for direct reference to Mbed TLS crypto that is not
# installed in /usr/local or some system location. The path names may
# need to be adjusted for your location of Mbed TLS
#CRYPTO_INC=-I ../../mbedtls/include/
CRYPTO_INC=-I ../mbedtls/include/
#CRYPTO_LIB=../../mbedtls/library/libmbedcrypto.a
CRYPTO_LIB=../mbedtls/build/library/libmbedcrypto.a

# These two are for reference to Mbed TLS that has been installed in
# /usr/local or in some system location.
CRYPTO_LIB=-l mbedcrypto
CRYPTO_INC=-I /usr/local/include
#CRYPTO_LIB=-l mbedcrypto
#CRYPTO_INC=-I /usr/local/include

CRYPTO_CONFIG_OPTS=-DT_COSE_USE_PSA_CRYPTO
CRYPTO_OBJ=crypto_adapters/t_cose_psa_crypto.o
Expand All @@ -59,7 +58,7 @@ CRYPTO_EXAMPLE_OBJ=examples/init_keys_psa.o
# ---- other configuration ----
# Use as needed. It has been used to disable features that aren't ready
# or that aren't passing tests
OTHER_OPTS=
OTHER_OPTS=-O0 -g


# ---- compiler configuration -----
Expand All @@ -83,7 +82,7 @@ CFLAGS=$(CMD_LINE) $(ALL_INC) $(C_OPTS) $(CRYPTO_CONFIG_OPTS) $(OTHER_OPTS)
# ---- The build targets ----
.PHONY: all install install_headers install_so uninstall clean warn

all: libt_cose.a t_cose_test t_cose_examples
all: libt_cose.a t_cose_test t_cose_examples hpke_test

# run "make warn" as a handy way to compile with the warning flags
# used in the QCBOR release process. See C_OPTS above.
Expand Down Expand Up @@ -124,6 +123,10 @@ t_cose_examples: $(EXAMPLE_OBJ) $(CRYPTO_EXAMPLE_OBJ) libt_cose.a
cc -o $@ $^ $(QCBOR_LIB) $(CRYPTO_LIB)


hpke_test: $(HPKE_TEST_OBJ) $(CRYPTO_EXAMPLE_OBJ) libt_cose.a
cc -o $@ $^ $(QCBOR_LIB) $(CRYPTO_LIB)


# ---- Installation ----
ifeq ($(PREFIX),)
PREFIX := /usr/local
Expand Down Expand Up @@ -153,6 +156,6 @@ uninstall: libt_cose.a $(PUBLIC_INTERFACE)

clean:
rm -f $(SRC_OBJ) $(TEST_OBJ) $(CRYPTO_OBJ) $(CRYPTO_TEST_OBJ) $(EXAMPLE_OBJ) $(CRYPTO_EXAMPLE_OBJ) \
t_cose_examples libt_cose.so \
t_cose_examples hpke_test libt_cose.so \
main.o t_cose_test libt_cose.a libt_cose.so

13 changes: 7 additions & 6 deletions Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
# This is for direct reference to QCBOR that is not installed in
# /usr/local or some system location. The path may need to be adjusted
# for your location of QCBOR.
#QCBOR_DIR=../../QCBOR/master
#QCBOR_INC=-I $(QCBOR_DIR)/inc
#QCBOR_LIB=$(QCBOR_DIR)/libqcbor.a
QCBOR_DIR=../QCBOR
QCBOR_INC=-I $(QCBOR_DIR)/inc
QCBOR_LIB=$(QCBOR_DIR)/build/libqcbor.a


# This is for reference to QCBOR that is installed in /usr/local or in
# some system location. This will typically use dynamic linking if
# there is a libqcbor.so
QCBOR_INC=-I /usr/local/include
QCBOR_LIB=-lqcbor
#QCBOR_INC=-I /usr/local/include
#QCBOR_LIB=-lqcbor


# ---- crypto configuration -----
Expand All @@ -50,7 +51,7 @@ CRYPTO_TEST_OBJ=examples/init_keys_test.o
# ---- other configuration ----
# Use as needed. It has been used to disable features that aren't ready
# or that aren't passing tests
OTHER_OPTS=-DT_COSE_ENABLE_HASH_FAIL_TEST -DT_COSE_DISABLE_SIGN_VERIFY_TESTS
OTHER_OPTS=-DT_COSE_ENABLE_HASH_FAIL_TEST -DT_COSE_DISABLE_SIGN_VERIFY_TESTS -DT_COSE_DISABLE_HPKE


# ---- compiler configuration -----
Expand Down
Loading

0 comments on commit 1f4ed74

Please sign in to comment.