1project(lws-crypto-cose-sign C) 2cmake_minimum_required(VERSION 2.8.12) 3find_package(libwebsockets CONFIG REQUIRED) 4list(APPEND CMAKE_MODULE_PATH ${LWS_CMAKE_DIR}) 5include(CheckCSourceCompiles) 6include(LwsCheckRequirements) 7 8set(SAMP lws-crypto-cose-sign) 9set(SRCS main.c) 10 11set(requirements 1) 12require_lws_config(LWS_WITH_COSE 1 requirements) 13 14if (requirements) 15 16 add_executable(${SAMP} ${SRCS}) 17 18 # EC signing 19 20 add_test(NAME crypto-cose-sign-1 21 COMMAND lws-crypto-cose-sign -s -k set1.cks --kid 11 22 --alg ES256 --cose-sign 23 --stdin payload.txt 24 --stdout ctest-sig-es256.sig) 25 add_test(NAME crypto-cose-sign-2 26 COMMAND lws-crypto-cose-sign -s -k set1.cks --kid sec384 27 --alg ES384 --cose-sign 28 --stdin payload.txt 29 --stdout ctest-sig-es384.sig) 30 add_test(NAME crypto-cose-sign-3 31 COMMAND lws-crypto-cose-sign -s -k set1.cks --kid sec512 32 --alg ES512 --cose-sign 33 --stdin payload.txt 34 --stdout ctest-sig-es512.sig) 35 36 # EC validation 37 38 add_test(NAME crypto-cose-sign-4 39 COMMAND lws-crypto-cose-sign -k set1.cks 40 --stdout r1.txt 41 --stdin ctest-sig-es256.sig) 42 set_tests_properties(crypto-cose-sign-4 PROPERTIES 43 DEPENDS crypto-cose-sign-1) 44 45 add_test(NAME crypto-cose-sign-5 46 COMMAND lws-crypto-cose-sign -k set1.cks 47 --stdout r2.txt 48 --stdin ctest-sig-es384.sig) 49 set_tests_properties(crypto-cose-sign-5 PROPERTIES 50 DEPENDS crypto-cose-sign-2) 51 52 add_test(NAME crypto-cose-sign-6 53 COMMAND lws-crypto-cose-sign -k set1.cks --cose-sign 54 --stdout r3.txt 55 --stdin ctest-sig-es512.sig) 56 set_tests_properties(crypto-cose-sign-6 PROPERTIES 57 DEPENDS crypto-cose-sign-3) 58 59 # RSA 4096 signing 60 61 add_test(NAME crypto-cose-sign-7 62 COMMAND lws-crypto-cose-sign -s -k rsa-4096.ck 63 --alg RS512 --cose-sign 64 --stdin payload.txt 65 --stdout ctest-sig-rs512.sig) 66 67 # RSA 4096 validation 68 69 add_test(NAME crypto-cose-sign-8 70 COMMAND lws-crypto-cose-sign -k rsa-4096.ck --cose-sign 71 --stdout r8.txt 72 --stdin ctest-sig-rs512.sig) 73 set_tests_properties(crypto-cose-sign-8 PROPERTIES 74 DEPENDS crypto-cose-sign-7) 75 76 # HMAC signing, cose-mac 77 78# add_test(NAME crypto-cose-sign-9 79# COMMAND lws-crypto-cose-sign -s -k set1.cks --kid our-secret 80# --alg HS256 --cose-mac 81# --stdin payload.txt 82# --stdout ctest-sig-hmac256.sig) 83# add_test(NAME crypto-cose-sign-10 84# COMMAND lws-crypto-cose-sign -s -k set1.cks --kid sec-48 85# --alg HS384 --cose-mac 86# --stdin payload.txt 87# --stdout ctest-sig-hmac384.sig) 88# add_test(NAME crypto-cose-sign-11 89# COMMAND lws-crypto-cose-sign -s -k set1.cks --kid sec-64 90# --alg HS512 --cose-mac 91# --stdin payload.txt 92# --stdout ctest-sig-hmac512.sig) 93# add_test(NAME crypto-cose-sign-12 94# COMMAND lws-crypto-cose-sign -s -k set1.cks --kid our-secret 95# --alg HS256_64 --cose-mac 96# --stdin payload.txt 97# --stdout ctest-sig-hmac256_64.sig) 98 99 # HMAC validation, cose-mac 100 101# add_test(NAME crypto-cose-sign-13 102# COMMAND lws-crypto-cose-sign -k set1.cks 103# --stdout r1.txt 104# --stdin ctest-sig-hmac256.sig) 105# set_tests_properties(crypto-cose-sign-13 106# PROPERTIES DEPENDS crypto-cose-sign-9) 107# 108# add_test(NAME crypto-cose-sign-14 109# COMMAND lws-crypto-cose-sign -k set1.cks 110# --stdout r2.txt 111# --stdin ctest-sig-hmac384.sig) 112# set_tests_properties(crypto-cose-sign-14 113# PROPERTIES DEPENDS crypto-cose-sign-10) 114# 115# add_test(NAME crypto-cose-sign-15 116# COMMAND lws-crypto-cose-sign -k set1.cks 117# --stdout r3.txt 118# --stdin ctest-sig-hmac512.sig) 119# set_tests_properties(crypto-cose-sign-15 120# PROPERTIES DEPENDS crypto-cose-sign-11) 121# 122# add_test(NAME crypto-cose-sign-16 123# COMMAND lws-crypto-cose-sign -k set1.cks 124# --stdout r4.txt 125# --stdin ctest-sig-hmac256_64.sig) 126# set_tests_properties(crypto-cose-sign-16 127# PROPERTIES DEPENDS crypto-cose-sign-12) 128 129 # HMAC signing, cose-mac0 130 131 add_test(NAME crypto-cose-sign-17 132 COMMAND lws-crypto-cose-sign -s -k set1.cks --kid our-secret 133 --alg HS256 --cose-mac0 134 --stdin payload.txt 135 --stdout ctest-sig-hmac0256.sig) 136 add_test(NAME crypto-cose-sign-18 137 COMMAND lws-crypto-cose-sign -s -k set1.cks --kid sec-48 138 --alg HS384 --cose-mac0 139 --stdin payload.txt 140 --stdout ctest-sig-hmac0384.sig) 141 add_test(NAME crypto-cose-sign-19 142 COMMAND lws-crypto-cose-sign -s -k set1.cks --kid sec-64 143 --alg HS512 --cose-mac0 144 --stdin payload.txt 145 --stdout ctest-sig-hmac0512.sig) 146 add_test(NAME crypto-cose-sign-20 147 COMMAND lws-crypto-cose-sign -s -k set1.cks --kid our-secret 148 --alg HS256_64 --cose-mac0 149 --stdin payload.txt 150 --stdout ctest-sig-hmac0256_64.sig) 151 152 # HMAC validation, cose-mac0 153 154 add_test(NAME crypto-cose-sign-21 155 COMMAND lws-crypto-cose-sign -k set1.cks 156 --stdout r1.txt 157 --stdin ctest-sig-hmac0256.sig) 158 set_tests_properties(crypto-cose-sign-21 159 PROPERTIES DEPENDS crypto-cose-sign-17) 160 161 add_test(NAME crypto-cose-sign-22 162 COMMAND lws-crypto-cose-sign -k set1.cks 163 --stdout r2.txt 164 --stdin ctest-sig-hmac0384.sig) 165 set_tests_properties(crypto-cose-sign-22 166 PROPERTIES DEPENDS crypto-cose-sign-18) 167 168 add_test(NAME crypto-cose-sign-23 169 COMMAND lws-crypto-cose-sign -k set1.cks 170 --stdout r3.txt 171 --stdin ctest-sig-hmac0512.sig) 172 set_tests_properties(crypto-cose-sign-23 173 PROPERTIES DEPENDS crypto-cose-sign-19) 174 175 add_test(NAME crypto-cose-sign-24 176 COMMAND lws-crypto-cose-sign -k set1.cks 177 --stdout r4.txt 178 --stdin ctest-sig-hmac0256_64.sig) 179 set_tests_properties(crypto-cose-sign-24 180 PROPERTIES DEPENDS crypto-cose-sign-20) 181 182 183 set_tests_properties(crypto-cose-sign-1 184 crypto-cose-sign-2 185 crypto-cose-sign-3 186 crypto-cose-sign-4 187 crypto-cose-sign-5 188 crypto-cose-sign-6 189 crypto-cose-sign-7 190 crypto-cose-sign-8 191# crypto-cose-sign-9 192# crypto-cose-sign-10 193# crypto-cose-sign-11 194# crypto-cose-sign-12 195# crypto-cose-sign-13 196# crypto-cose-sign-14 197# crypto-cose-sign-15 198# crypto-cose-sign-16 199 crypto-cose-sign-17 200 crypto-cose-sign-18 201 crypto-cose-sign-19 202 crypto-cose-sign-20 203 crypto-cose-sign-21 204 crypto-cose-sign-22 205 crypto-cose-sign-23 206 crypto-cose-sign-24 207 208 PROPERTIES 209 WORKING_DIRECTORY 210 ${CMAKE_SOURCE_DIR}/minimal-examples/crypto/minimal-crypto-cose-sign 211 TIMEOUT 5) 212 213 if (websockets_shared) 214 target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS}) 215 add_dependencies(${SAMP} websockets_shared) 216 else() 217 target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS}) 218 endif() 219endif() 220