Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable running unsigned code #78

Merged
merged 1 commit into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")

if ($ENV{TARGET} MATCHES "nCipher")
include(codesafe.cmake)

if ($ENV{UNSIGNED} MATCHES "yes")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having 3 parameters, should we have a single parameter (which picks among 4 profiles)? The 4 profiles would be:

  • dev-without-hsm = no HSM, btc-testnet
  • dev-with-hsm = HSM, unsigned, btc-testnet
  • staging = HSM, signed, btc-testnet
  • prod = HSM, signed, btc-mainnet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, having profiles will be cleaner (and we can document the list above)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNSIGNED")
endif ()
endif ()

add_subdirectory(trezor-crypto)
Expand All @@ -20,9 +24,9 @@ include_directories(include nanopb trezor-crypto "${CMAKE_BINARY_DIR}/proto")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-unknown-pragmas")

if ($ENV{CURRENCY} MATCHES "btc-testnet")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBTC_TESTNET -Werror -Wno-unknown-pragmas")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBTC_TESTNET")
elseif ($ENV{CURRENCY} MATCHES "btc-mainnet")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBTC_MAINNET -Werror -Wno-unknown-pragmas")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBTC_MAINNET")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more -Werror?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already set above: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-unknown-pragmas")

endif ()

set(main_SRC
Expand Down
19 changes: 17 additions & 2 deletions core/codesafe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,29 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mpowerpc -mcpu=e5500 -mno-toc -mbig-endian
set(CMAKE_C_LINK_EXECUTABLE
"${CODESAFE_GCC} -Wl,-wrap=read -Wl,-wrap=write -Wl,-wrap=socket -Wl,-wrap=send -Wl,-wrap=sendto -Wl,-wrap=recv -Wl,-wrap=recvfrom -Wl,-wrap=listen -Wl,-wrap=connect -Wl,-wrap=bind -Wl,-wrap=setsockopt -Wl,-wrap=select -Wl,-wrap=accept -Wl,-wrap=poll -Bstatic -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/hoststdioeinetsocks.o ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libfaksys.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libcutils.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libvfsextras.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libseewrpr.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libipccore.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libsolotrace.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libnfstub.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libfaksys.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libseewrpr.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/seelib.a ${NFAST_PATH}/c/csd/lib-ppc-linux-gcc/libipccore.a -lpthread -lrt")

add_custom_command(OUTPUT subzero-unsigned.ar
DEPENDS subzero
COMMAND ${NFAST_PATH}/bin/tct2 --pack --infile=subzero --outfile subzero-unsigned.ar
)

add_custom_command(OUTPUT subzero.cpio
COMMAND echo dummy > dummy
COMMAND ${NFAST_PATH}/bin/cpioc subzero.cpio dummy
)

add_custom_target(run-unsigned
DEPENDS subzero-unsigned.ar subzero.cpio
COMMAND sudo ${NFAST_PATH}/bin/nopclearfail -c -a
COMMAND sudo ${NFAST_PATH}/bin/see-stdioesock-serv --machine subzero-unsigned.ar --userdata-raw subzero.cpio
)

add_custom_command(OUTPUT subzero-signed.sar
DEPENDS subzero
COMMAND ${NFAST_PATH}/bin/tct2 --sign-and-pack --key=subzerosigner --is-machine --machine-type=PowerPCELF --infile=subzero --outfile subzero-signed.sar
)

add_custom_command(OUTPUT subzero-userdata-signed.sar
COMMAND echo dummy > dummy
COMMAND ${NFAST_PATH}/bin/cpioc subzero.cpio dummy
DEPENDS subzero.cpio
COMMAND ${NFAST_PATH}/bin/tct2 --sign-and-pack --key=subzerodatasigner --machine-key-ident=subzerosigner --infile=subzero.cpio --outfile subzero-userdata-signed.sar
)

Expand Down
3 changes: 3 additions & 0 deletions core/src/ncipher/module_certificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Result module_certificate_init(M_CertificateList *cert_list, M_Certificate *cert
INFO("Got %d signers", signer_count);
if (signer_count == 0) {
NFastApp_Free_Reply(app, NULL, NULL, &reply);
#ifdef UNSIGNED
return Result_SUCCESS;
#endif
return Result_GET_MODULE_CERTIFICATE_NO_SIGNERS;
}

Expand Down