├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.md └── workflows │ └── githubci.yml ├── LICENSE ├── README.md ├── examples ├── hash │ ├── .feather52832.test.skip │ ├── .feather52833.test.skip │ ├── hash.ino │ └── input_data.bin ├── hmac │ ├── .feather52832.test.skip │ ├── .feather52833.test.skip │ └── hmac.ino └── random │ ├── .feather52832.test.skip │ ├── .feather52833.test.skip │ └── random.ino ├── extra_script.py ├── library.json ├── library.properties └── src ├── Adafruit_nRFCrypto.cpp ├── Adafruit_nRFCrypto.h ├── cortex-m4 ├── fpv4-sp-d16-hard │ └── libnrf_cc310_0.9.13-no-interrupts.a └── license.txt ├── ecc ├── nRFCrypto_ECC.cpp ├── nRFCrypto_ECC.h ├── nRFCrypto_ECC_PrivateKey.cpp ├── nRFCrypto_ECC_PrivateKey.h ├── nRFCrypto_ECC_PublicKey.cpp └── nRFCrypto_ECC_PublicKey.h ├── nRFCrypto_Hash.cpp ├── nRFCrypto_Hash.h ├── nRFCrypto_Hmac.cpp ├── nRFCrypto_Hmac.h ├── nRFCrypto_Random.cpp ├── nRFCrypto_Random.h └── nrf_cc310 ├── include ├── ccsw_crys_rsa_shared_types.h ├── crys_aesccm.h ├── crys_aesccm_error.h ├── crys_chacha.h ├── crys_chacha_error.h ├── crys_chacha_poly.h ├── crys_chacha_poly_error.h ├── crys_common.h ├── crys_common_error.h ├── crys_dh.h ├── crys_dh_error.h ├── crys_dh_kg.h ├── crys_ec_edw_api.h ├── crys_ec_mont_api.h ├── crys_ec_mont_edw_error.h ├── crys_ecpki_build.h ├── crys_ecpki_dh.h ├── crys_ecpki_domain.h ├── crys_ecpki_ecdsa.h ├── crys_ecpki_error.h ├── crys_ecpki_kg.h ├── crys_ecpki_types.h ├── crys_error.h ├── crys_hash.h ├── crys_hash_defs.h ├── crys_hash_error.h ├── crys_hkdf.h ├── crys_hkdf_error.h ├── crys_hmac.h ├── crys_hmac_defs.h ├── crys_hmac_error.h ├── crys_kdf.h ├── crys_kdf_error.h ├── crys_pka_defs_hw.h ├── crys_poly.h ├── crys_poly_error.h ├── crys_rnd.h ├── crys_rnd_error.h ├── crys_rsa_build.h ├── crys_rsa_error.h ├── crys_rsa_kg.h ├── crys_rsa_prim.h ├── crys_rsa_schemes.h ├── crys_rsa_types.h ├── crys_srp.h ├── crys_srp_error.h ├── dx_reg_base_host.h ├── sns_silib.h ├── ssi_aes.h ├── ssi_aes_defs.h ├── ssi_aes_error.h ├── ssi_bitops.h ├── ssi_pal_abort.h ├── ssi_pal_barrier.h ├── ssi_pal_compiler.h ├── ssi_pal_dma.h ├── ssi_pal_dma_defs.h ├── ssi_pal_dma_plat.h ├── ssi_pal_error.h ├── ssi_pal_file.h ├── ssi_pal_file_plat.h ├── ssi_pal_fips.h ├── ssi_pal_init.h ├── ssi_pal_list.h ├── ssi_pal_log.h ├── ssi_pal_mem.h ├── ssi_pal_memmap.h ├── ssi_pal_mutex.h ├── ssi_pal_mutex_plat.h ├── ssi_pal_perf.h ├── ssi_pal_perf_plat.h ├── ssi_pal_sem.h ├── ssi_pal_sem_plat.h ├── ssi_pal_trng.h ├── ssi_pal_types.h ├── ssi_pal_types_plat.h ├── ssi_pka_hw_plat_defs.h ├── ssi_regs.h ├── ssi_sram_map.h ├── ssi_util_defs.h ├── ssi_util_error.h ├── ssi_util_key_derivation.h └── ssi_util_key_derivation_defs.h └── license.txt /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Report a problem 3 | labels: 'Bug' 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to fill out this bug report! 9 | It's okay to leave some blank if it doesn't apply to your problem. 10 | 11 | - type: dropdown 12 | attributes: 13 | label: Operating System 14 | options: 15 | - Linux 16 | - MacOS 17 | - RaspberryPi OS 18 | - Windows 7 19 | - Windows 10 20 | - Windows 11 21 | - Others 22 | validations: 23 | required: true 24 | 25 | - type: input 26 | attributes: 27 | label: IDE version 28 | placeholder: e.g Arduino 1.8.15 29 | validations: 30 | required: true 31 | 32 | - type: input 33 | attributes: 34 | label: Board 35 | placeholder: e.g Feather nRF52840 Express 36 | validations: 37 | required: true 38 | 39 | - type: input 40 | attributes: 41 | label: BSP version 42 | description: Can be found under "Board Manager" menu 43 | validations: 44 | required: true 45 | 46 | - type: input 47 | attributes: 48 | label: SPIFlash Library version 49 | placeholder: "Release version or github latest" 50 | validations: 51 | required: true 52 | 53 | - type: textarea 54 | attributes: 55 | label: Sketch 56 | placeholder: | 57 | e.g examples/flash_info 58 | If it is custom sketch, please provide links to your minimal sources or as attached files. 59 | validations: 60 | required: true 61 | 62 | - type: textarea 63 | attributes: 64 | label: What happened ? 65 | placeholder: A clear and concise description of what the bug is. 66 | validations: 67 | required: true 68 | 69 | - type: textarea 70 | attributes: 71 | label: How to reproduce ? 72 | placeholder: | 73 | 1. Go to '...' 74 | 2. Click on '....' 75 | 3. See error 76 | validations: 77 | required: true 78 | 79 | - type: textarea 80 | attributes: 81 | label: Debug Log 82 | placeholder: | 83 | Debug log where the issue occurred as attached txt file, best with comments to explain the actual events. 84 | validations: 85 | required: false 86 | 87 | - type: textarea 88 | attributes: 89 | label: Screenshots 90 | description: If applicable, add screenshots to help explain your problem. 91 | validations: 92 | required: false 93 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Adafruit Support Forum 3 | url: https://forums.adafruit.com 4 | about: If you have other questions or need help, post it here. 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: Feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [pull_request, push, repository_dispatch] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | arduino-platform: 11 | - 'clue' 12 | - 'cpb' 13 | - 'nrf52840' 14 | 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Setup Python 18 | uses: actions/setup-python@v4 19 | with: 20 | python-version: '3.x' 21 | 22 | - name: Checkout code 23 | uses: actions/checkout@v3 24 | 25 | - name: Checkout adafruit/ci-arduino 26 | uses: actions/checkout@v3 27 | with: 28 | repository: adafruit/ci-arduino 29 | path: ci 30 | 31 | - name: pre-install 32 | run: bash ci/actions_install.sh 33 | 34 | - name: test platforms 35 | run: python3 ci/build_platform.py ${{ matrix.arduino-platform }} 36 | 37 | # - name: clang 38 | # skip clang for fatfs (ff) to make it easier to compare and upgrade 39 | # run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -e "./examples/SdFat_format/*" -r . 40 | 41 | # - name: doxygen 42 | # env: 43 | # GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 44 | # PRETTYNAME : "Adafruit SPIFlash Library" 45 | # run: bash ci/doxy_gen_and_deploy.sh 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Adafruit Industries 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adafruit nRFCrypto 2 | 3 | Adafruit Arduino Cryptography Library using hardware-accelerated ARM CryptoCell CC310 on nRF52-based Bluefruit. CryptoCell CC310 is only available on nRF52840 therefore nRF52832 is not supported by this library. 4 | 5 | Although this library license is MIT, it uses ARM precompiled static library, which has its own [licence here](src/cortex-m4/license.txt). Please make sure you understand all the license term for files you use in your project. 6 | -------------------------------------------------------------------------------- /examples/hash/.feather52832.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/examples/hash/.feather52832.test.skip -------------------------------------------------------------------------------- /examples/hash/.feather52833.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/examples/hash/.feather52833.test.skip -------------------------------------------------------------------------------- /examples/hash/hash.ino: -------------------------------------------------------------------------------- 1 | #include "Adafruit_nRFCrypto.h" 2 | #include // for Serial 3 | 4 | /* Input data for testing 5 | * Same data is stored in input_data.bin file, to verify the result, run hash sum on your PC 6 | * and compare the result with this sketch 7 | * 8 | * $ sha1sum input_data.bin 9 | * 9f9da10ec23735930089a8f89b34f7b5d267903e 10 | * 11 | * $ sha224sum input_data.bin 12 | * 68abe34d09a758be6b2fb3a7a997983a639687099d35406f927a5cc5 13 | * 14 | * $ sha256sum input_data.bin 15 | * 75cfb39b62c474921e2aad979c210f8b69180a9d58e9f296a4b9904ae6e7aa40 16 | * 17 | * $ sha512sum input_data.bin 18 | * e3979c6296e282af04619992f71addfefd118be26626cedd715edced36b87058f868b316e725b24e1e7f661ce2935e44ba4deea62afa3e13188071403a2f1463 19 | */ 20 | uint8_t input_data[] = 21 | { 22 | 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 23 | 0x65, 0xa2, 0x32, 0xd6, 0xbc, 0xd0, 0xf9, 0x39, 0xed, 0x1f, 0xe1, 0x28, 0xc1, 0x3b, 0x0e, 0x1b 24 | }; 25 | 26 | nRFCrypto_Hash hash; 27 | 28 | // the setup function runs once when you press reset or power the board 29 | void setup() 30 | { 31 | // initialize digital pin LED_BUILTIN as an output. 32 | pinMode(LED_BUILTIN, OUTPUT); 33 | 34 | while( !Serial) delay(10); 35 | Serial.println("nRFCrypto Hash example"); 36 | 37 | nRFCrypto.begin(); 38 | 39 | test_hash(CRYS_HASH_SHA1_mode , "SHA-1"); 40 | test_hash(CRYS_HASH_SHA224_mode , "SHA-224"); 41 | test_hash(CRYS_HASH_SHA256_mode , "SHA-256"); 42 | test_hash(CRYS_HASH_SHA512_mode , "SHA-512"); 43 | 44 | // Note: SHA384 and MD5 currently cause hardfault 45 | // test_hash(CRYS_HASH_SHA384_mode , "SHA384"); 46 | // test_hash(CRYS_HASH_MD5_mode , "MD5"); 47 | 48 | nRFCrypto.end(); 49 | 50 | } 51 | 52 | void test_hash(uint32_t mode, const char* modestr) 53 | { 54 | uint32_t result[16]; 55 | uint8_t result_len; // depending on Hash mode 56 | 57 | hash.begin(mode); 58 | hash.update(input_data, sizeof(input_data)); 59 | result_len = hash.end(result); 60 | 61 | Serial.print(" "); 62 | Serial.flush(); 63 | Serial.println(modestr); 64 | 65 | Serial.printBuffer( (uint8_t*) result, result_len, ' ', 16); 66 | 67 | Serial.println(); 68 | Serial.println(); 69 | 70 | Serial.flush(); 71 | } 72 | 73 | void loop() 74 | { 75 | digitalToggle(LED_BUILTIN); 76 | delay(1000); 77 | } 78 | -------------------------------------------------------------------------------- /examples/hash/input_data.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/examples/hash/input_data.bin -------------------------------------------------------------------------------- /examples/hmac/.feather52832.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/examples/hmac/.feather52832.test.skip -------------------------------------------------------------------------------- /examples/hmac/.feather52833.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/examples/hmac/.feather52833.test.skip -------------------------------------------------------------------------------- /examples/hmac/hmac.ino: -------------------------------------------------------------------------------- 1 | #include "Adafruit_nRFCrypto.h" 2 | #include // for Serial 3 | 4 | /* Input data for testing 5 | * to verify the result, run openssl on your PC 6 | * and compare the result with this sketch 7 | * 8 | * $ echo -ne "Hello World!" | openssl dgst -sha1 -hmac "secret" 9 | * (stdin)= 5efed98b0787c83f9cb0135ba283c390ca49320e 10 | * 11 | * $ echo -ne "Hello World!" | openssl dgst -sha224 -hmac "secret" 12 | * (stdin)= d1f9ff720c7558366f2b67e672b4f4ee7cb58b5803cd9e46380123f2 13 | * 14 | * $ echo -ne "Hello World!" | openssl dgst -sha256 -hmac "secret" 15 | * (stdin)= 6fa7b4dea28ee348df10f9bb595ad985ff150a4adfd6131cca677d9acee07dc6 16 | * 17 | * $ echo -ne "Hello World!" | openssl dgst -sha512 -hmac "secret" 18 | * (stdin)= fd3716eb8e1903ecb8deb9320f1baecf0f8dbe04e4c4c71e64fbb37080222ca42deb0b646cabeb53e269a2446507fb5442961656f8007959bd330ef48df0e13e 19 | */ 20 | uint8_t input_data[] = // "Hello World!" 21 | { 22 | 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 23 | 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21 24 | }; 25 | 26 | uint8_t key[] = // "secret" 27 | { 28 | 0x73, 0x65, 0x63, 0x72, 0x65, 0x74 29 | }; 30 | 31 | nRFCrypto_Hmac hmac; 32 | 33 | // the setup function runs once when you press reset or power the board 34 | void setup() 35 | { 36 | // initialize digital pin LED_BUILTIN as an output. 37 | pinMode(LED_BUILTIN, OUTPUT); 38 | 39 | while( !Serial) delay(10); 40 | Serial.println("nRFCrypto Hmac example"); 41 | 42 | nRFCrypto.begin(); 43 | 44 | test_hmac(CRYS_HASH_SHA1_mode , "SHA-1"); 45 | test_hmac(CRYS_HASH_SHA224_mode , "SHA-224"); 46 | test_hmac(CRYS_HASH_SHA256_mode , "SHA-256"); 47 | test_hmac(CRYS_HASH_SHA512_mode , "SHA-512"); 48 | 49 | nRFCrypto.end(); 50 | } 51 | 52 | void test_hmac(CRYS_HASH_OperationMode_t mode, const char* modestr) 53 | { 54 | uint32_t result[16]; 55 | uint8_t result_len; // depending on Hash mode 56 | 57 | hmac.begin(mode, key, sizeof(key)); 58 | hmac.update(input_data, sizeof(input_data)); 59 | result_len = hmac.end(result); 60 | 61 | Serial.print(" "); 62 | Serial.flush(); 63 | Serial.println(modestr); 64 | 65 | Serial.printBuffer( (uint8_t*) result, result_len, ' ', 16); 66 | 67 | Serial.println(); 68 | Serial.println(); 69 | 70 | Serial.flush(); 71 | } 72 | 73 | void loop() 74 | { 75 | digitalToggle(LED_BUILTIN); 76 | delay(1000); 77 | } 78 | -------------------------------------------------------------------------------- /examples/random/.feather52832.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/examples/random/.feather52832.test.skip -------------------------------------------------------------------------------- /examples/random/.feather52833.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/examples/random/.feather52833.test.skip -------------------------------------------------------------------------------- /examples/random/random.ino: -------------------------------------------------------------------------------- 1 | #include "Adafruit_nRFCrypto.h" 2 | #include // for Serial 3 | 4 | // Bufer to hold randomized data 5 | uint8_t buffer[32]; 6 | 7 | // the setup function runs once when you press reset or power the board 8 | void setup() 9 | { 10 | // initialize digital pin LED_BUILTIN as an output. 11 | pinMode(LED_BUILTIN, OUTPUT); 12 | 13 | // while(!Serial) delay(10); 14 | Serial.println("nRFCrypto Random example"); 15 | delay(10); 16 | 17 | nRFCrypto.begin(); 18 | } 19 | 20 | void loop() 21 | { 22 | // Generate new random 32 bytes every 1 second 23 | nRFCrypto.Random.generate(buffer, sizeof(buffer)); 24 | 25 | // Print to Serial 26 | Serial.printBuffer(buffer, sizeof(buffer)); 27 | Serial.println(); 28 | 29 | digitalToggle(LED_BUILTIN); 30 | delay(1000); 31 | } 32 | -------------------------------------------------------------------------------- /extra_script.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | env = DefaultEnvironment() 4 | 5 | # An extra script is required to properly handle extra link flags set in 6 | # the `library.properties` file 7 | if env.BoardConfig().get("build.mcu", "").startswith("nrf5284"): 8 | env.Append( 9 | LIBPATH=[os.path.realpath("src/cortex-m4/fpv4-sp-d16-hard")], 10 | LIBS=["nrf_cc310_0.9.13-no-interrupts"] 11 | ) 12 | env.Append( 13 | CPPDEFINES=[("NRF_CRYPTOCELL", "((NRF_CRYPTOCELL_Type*) NRF_CRYPTOCELL_BASE)")], 14 | ) -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Adafruit nRFCrypto", 3 | "build": { 4 | "extraScript": "extra_script.py" 5 | } 6 | } -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit nRFCrypto 2 | version=0.1.2 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino Cryptography library using hardware-accelerated ARM CryptoCell CC310 on nRF52-based Adafruit Bluefruit LE modules 6 | paragraph=Arduino Cryptography library using hardware-accelerated ARM CryptoCell CC310 on nRF52-based Adafruit Bluefruit LE modules 7 | category=Data Processing 8 | url=https://github.com/adafruit/Adafruit_nRFCrypto 9 | architectures=* 10 | includes=Adafruit_nRFCrypto.h 11 | precompiled=true 12 | ldflags=-lnrf_cc310_0.9.13-no-interrupts 13 | -------------------------------------------------------------------------------- /src/Adafruit_nRFCrypto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef ADAFRUIT_NRFCRYPTO_H_ 26 | #define ADAFRUIT_NRFCRYPTO_H_ 27 | 28 | #include "common_inc.h" 29 | #include "rtos.h" 30 | 31 | #include "nRFCrypto_Random.h" 32 | #include "nRFCrypto_Hash.h" 33 | #include "nRFCrypto_Hmac.h" 34 | #include "ecc/nRFCrypto_ECC.h" 35 | 36 | class Adafruit_nRFCrypto 37 | { 38 | public: 39 | Adafruit_nRFCrypto(void); 40 | 41 | bool begin(void); 42 | void end(void); 43 | 44 | nRFCrypto_Random Random; 45 | 46 | private: 47 | bool _begun; 48 | }; 49 | 50 | extern Adafruit_nRFCrypto nRFCrypto; 51 | 52 | #if !CFG_DEBUG 53 | #define VERIFY_CRYS VERIFY_ERROR 54 | #else 55 | #define VERIFY_CRYS(...) _GET_3RD_ARG(__VA_ARGS__, VERIFY_ERR_2ARGS, VERIFY_ERR_1ARGS)(__VA_ARGS__, dbg_strerr_crys) 56 | const char* dbg_strerr_crys(int32_t err); 57 | #endif 58 | 59 | #endif /* ADAFRUIT_NRFCRYPTO_H_ */ 60 | -------------------------------------------------------------------------------- /src/cortex-m4/fpv4-sp-d16-hard/libnrf_cc310_0.9.13-no-interrupts.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRFCrypto/2be11062ac56cf75a9a8b8ed087ad495421403f4/src/cortex-m4/fpv4-sp-d16-hard/libnrf_cc310_0.9.13-no-interrupts.a -------------------------------------------------------------------------------- /src/cortex-m4/license.txt: -------------------------------------------------------------------------------- 1 | ARM Object Code and Header Files License 2 | Version 1.0 3 | 4 | Redistribution. 5 | 6 | Redistribution and use of object code, header files, and 7 | documentation, without modification, are permitted provided that the following 8 | conditions are met: 9 | 1) Redistributions must reproduce the above copyright notice and the 10 | following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 2) Unless to the extent explicitly permitted by law, no reverse 13 | engineering, decompilation, or disassembly of is permitted. 14 | 3) Redistribution and use is permitted solely for the purpose of 15 | developing or executing applications that are targeted for use 16 | on an ARM-based product. 17 | 18 | DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 20 | NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, 21 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /src/ecc/nRFCrypto_ECC.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "nrf_cc310/include/crys_ecpki_kg.h" 26 | #include "nrf_cc310/include/crys_ecpki_dh.h" 27 | 28 | #include "Adafruit_nRFCrypto.h" 29 | 30 | //--------------------------------------------------------------------+ 31 | // MACRO TYPEDEF CONSTANT ENUM DECLARATION 32 | //--------------------------------------------------------------------+ 33 | 34 | //--------------------------------------------------------------------+ 35 | // ECC 36 | //--------------------------------------------------------------------+ 37 | 38 | bool nRFCrypto_ECC::genKeyPair(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& public_key) 39 | { 40 | VERIFY( private_key.getDomain() == public_key.getDomain() ); 41 | 42 | CRYS_ECPKI_KG_TempData_t* tempbuf = (CRYS_ECPKI_KG_TempData_t*) rtos_malloc( sizeof(CRYS_ECPKI_KG_TempData_t) ); 43 | VERIFY(tempbuf); 44 | 45 | uint32_t err = CRYS_ECPKI_GenKeyPair(nRFCrypto.Random.getContext(), CRYS_RND_GenerateVector, private_key.getDomain(), 46 | &private_key._key, &public_key._key, 47 | tempbuf, NULL); 48 | rtos_free(tempbuf); 49 | 50 | VERIFY_CRYS(err, false); 51 | return true; 52 | } 53 | 54 | uint32_t nRFCrypto_ECC::SVDP_DH(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& peer_pubkey, uint8_t* shared_secret, uint32_t bufsize) 55 | { 56 | CRYS_ECDH_TempData_t* tempbuf = (CRYS_ECDH_TempData_t *) rtos_malloc(sizeof(CRYS_ECDH_TempData_t)); 57 | VERIFY(tempbuf); 58 | 59 | uint32_t err = CRYS_ECDH_SVDP_DH(&peer_pubkey._key, &private_key._key, shared_secret, &bufsize, tempbuf); 60 | 61 | rtos_free(tempbuf); 62 | 63 | VERIFY_CRYS(err, 0); 64 | return bufsize; 65 | } 66 | 67 | nRFCrypto_ECC::nRFCrypto_ECC(void) 68 | { 69 | 70 | } 71 | 72 | bool nRFCrypto_ECC::begin(void) 73 | { 74 | return true; 75 | } 76 | 77 | void nRFCrypto_ECC::end(void) 78 | { 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/ecc/nRFCrypto_ECC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef NRFCRYPTO_ECC_H_ 26 | #define NRFCRYPTO_ECC_H_ 27 | 28 | #include "nrf_cc310/include/crys_ecpki_types.h" 29 | #include "nrf_cc310/include/crys_ecpki_error.h" 30 | #include "nrf_cc310/include/crys_ecpki_domain.h" 31 | 32 | #include "nRFCrypto_ECC_PublicKey.h" 33 | #include "nRFCrypto_ECC_PrivateKey.h" 34 | 35 | class nRFCrypto_ECC 36 | { 37 | public: 38 | //------------- Static Members -------------// 39 | static bool genKeyPair(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& public_key); 40 | static uint32_t SVDP_DH(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& peer_pubkey, uint8_t* shared_secret, uint32_t bufsize); 41 | 42 | public: 43 | nRFCrypto_ECC(void); 44 | bool begin(void); 45 | void end(void); 46 | 47 | private: 48 | 49 | }; 50 | 51 | #endif /* NRFCRYPTO_ECC_H_ */ 52 | -------------------------------------------------------------------------------- /src/ecc/nRFCrypto_ECC_PrivateKey.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | 26 | #include "nrf_cc310/include/crys_ecpki_build.h" 27 | 28 | #include "Adafruit_nRFCrypto.h" 29 | 30 | //--------------------------------------------------------------------+ 31 | // MACRO TYPEDEF CONSTANT ENUM DECLARATION 32 | //--------------------------------------------------------------------+ 33 | 34 | 35 | //------------- IMPLEMENTATION -------------// 36 | nRFCrypto_ECC_PrivateKey::nRFCrypto_ECC_PrivateKey(void) 37 | { 38 | _domain = NULL; 39 | } 40 | 41 | bool nRFCrypto_ECC_PrivateKey::begin(CRYS_ECPKI_DomainID_t id) 42 | { 43 | _domain = CRYS_ECPKI_GetEcDomain(id); 44 | return _domain != NULL; 45 | } 46 | 47 | void nRFCrypto_ECC_PrivateKey::end(void) 48 | { 49 | _domain = NULL; 50 | } 51 | 52 | // Export from internal type to raw bytes in Big Endian 53 | // return raw buffer size = keysize + 1 (header) 54 | uint32_t nRFCrypto_ECC_PrivateKey::toRaw(uint8_t* buffer, uint32_t bufsize) 55 | { 56 | VERIFY_CRYS(CRYS_ECPKI_ExportPrivKey(&_key, buffer, &bufsize), 0); 57 | return bufsize; 58 | } 59 | 60 | // Build public key from raw bytes in Big Endian 61 | bool nRFCrypto_ECC_PrivateKey::fromRaw(uint8_t* buffer, uint32_t bufsize) 62 | { 63 | VERIFY_CRYS(CRYS_ECPKI_BuildPrivKey(_domain, buffer, bufsize, &_key), false); 64 | return true; 65 | } 66 | -------------------------------------------------------------------------------- /src/ecc/nRFCrypto_ECC_PrivateKey.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef NRFCRYPTO_ECC_PRIVATEKEY_H_ 26 | #define NRFCRYPTO_ECC_PRIVATEKEY_H_ 27 | 28 | class nRFCrypto_ECC; 29 | 30 | class nRFCrypto_ECC_PrivateKey 31 | { 32 | public: 33 | nRFCrypto_ECC_PrivateKey(void); 34 | 35 | bool begin(CRYS_ECPKI_DomainID_t id); 36 | void end(void); 37 | 38 | const CRYS_ECPKI_Domain_t* getDomain(void) { return _domain; } 39 | 40 | uint32_t toRaw(uint8_t* buffer, uint32_t bufsize); 41 | bool fromRaw(uint8_t* buffer, uint32_t bufsize); 42 | 43 | private: 44 | const CRYS_ECPKI_Domain_t* _domain; 45 | CRYS_ECPKI_UserPrivKey_t _key; 46 | 47 | friend class nRFCrypto_ECC; 48 | }; 49 | 50 | #endif /* NRFCRYPTO_ECC_PRIVATEKEY_H_ */ 51 | -------------------------------------------------------------------------------- /src/ecc/nRFCrypto_ECC_PublicKey.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "nrf_cc310/include/crys_ecpki_build.h" 26 | 27 | #include "Adafruit_nRFCrypto.h" 28 | 29 | 30 | //--------------------------------------------------------------------+ 31 | // MACRO TYPEDEF CONSTANT ENUM DECLARATION 32 | //--------------------------------------------------------------------+ 33 | 34 | 35 | //------------- IMPLEMENTATION -------------// 36 | nRFCrypto_ECC_PublicKey::nRFCrypto_ECC_PublicKey(void) 37 | { 38 | _domain = NULL; 39 | } 40 | 41 | bool nRFCrypto_ECC_PublicKey::begin(CRYS_ECPKI_DomainID_t id) 42 | { 43 | _domain = CRYS_ECPKI_GetEcDomain(id); 44 | return _domain != NULL; 45 | } 46 | 47 | void nRFCrypto_ECC_PublicKey::end(void) 48 | { 49 | _domain = NULL; 50 | } 51 | 52 | // Export from internal type to raw bytes in Big Endian 53 | // return raw buffer size = keysize + 1 (header) 54 | uint32_t nRFCrypto_ECC_PublicKey::toRaw(uint8_t* buffer, uint32_t bufsize) 55 | { 56 | VERIFY_CRYS(CRYS_ECPKI_ExportPublKey(&_key, CRYS_EC_PointUncompressed, buffer, &bufsize), 0); 57 | return bufsize; 58 | } 59 | 60 | // Build public key from raw bytes in Big Endian 61 | bool nRFCrypto_ECC_PublicKey::fromRaw(uint8_t* buffer, uint32_t bufsize) 62 | { 63 | CRYS_ECPKI_BUILD_TempData_t* tempbuf = (CRYS_ECPKI_BUILD_TempData_t*) rtos_malloc( sizeof(CRYS_ECPKI_BUILD_TempData_t) ); 64 | VERIFY(tempbuf); 65 | 66 | uint32_t err = CRYS_ECPKI_BuildPublKeyPartlyCheck(_domain, buffer, bufsize, &_key, tempbuf); 67 | 68 | rtos_free(tempbuf); 69 | 70 | VERIFY_CRYS(err, false); 71 | return true; 72 | } 73 | -------------------------------------------------------------------------------- /src/ecc/nRFCrypto_ECC_PublicKey.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef NRFCRYPTO_ECC_PUBLICKEY_H_ 26 | #define NRFCRYPTO_ECC_PUBLICKEY_H_ 27 | 28 | class nRFCrypto_ECC; 29 | 30 | class nRFCrypto_ECC_PublicKey 31 | { 32 | public: 33 | nRFCrypto_ECC_PublicKey(void); 34 | 35 | bool begin(CRYS_ECPKI_DomainID_t id); 36 | void end(void); 37 | 38 | const CRYS_ECPKI_Domain_t* getDomain(void) { return _domain; } 39 | 40 | uint32_t toRaw(uint8_t* buffer, uint32_t bufsize); 41 | bool fromRaw(uint8_t* buffer, uint32_t bufsize); 42 | 43 | private: 44 | const CRYS_ECPKI_Domain_t* _domain; 45 | CRYS_ECPKI_UserPublKey_t _key; 46 | 47 | friend class nRFCrypto_ECC; 48 | }; 49 | 50 | 51 | #endif /* NRFCRYPTO_ECC_PUBLICKEY_H_ */ 52 | -------------------------------------------------------------------------------- /src/nRFCrypto_Hash.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "Adafruit_nRFCrypto.h" 26 | 27 | //--------------------------------------------------------------------+ 28 | // MACRO TYPEDEF CONSTANT ENUM DECLARATION 29 | //--------------------------------------------------------------------+ 30 | 31 | // Length of Digest Op mode in bytes 32 | static const uint8_t digest_len_arr[] = 33 | { 34 | CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES, 35 | CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES, 36 | CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES, 37 | CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES, 38 | CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES, 39 | CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES 40 | }; 41 | 42 | 43 | //------------- IMPLEMENTATION -------------// 44 | nRFCrypto_Hash::nRFCrypto_Hash(void) 45 | { 46 | _digest_len = 0; 47 | } 48 | 49 | bool nRFCrypto_Hash::begin(CRYS_HASH_OperationMode_t mode) 50 | { 51 | VERIFY_ERROR( CRYS_HASH_Init(&_context, mode), false ); 52 | if ( mode < CRYS_HASH_NumOfModes ) _digest_len = digest_len_arr[mode]; 53 | 54 | return true; 55 | } 56 | 57 | bool nRFCrypto_Hash::update(uint8_t data[], size_t size) 58 | { 59 | VERIFY_ERROR( CRYS_HASH_Update(&_context, data, size), false ); 60 | return true; 61 | } 62 | 63 | uint8_t nRFCrypto_Hash::end(uint32_t result[16]) 64 | { 65 | VERIFY_ERROR( CRYS_HASH_Finish(&_context, result), 0); 66 | return _digest_len; 67 | } 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/nRFCrypto_Hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef NRFCRYPTO_HASH_H_ 26 | #define NRFCRYPTO_HASH_H_ 27 | 28 | #include "nrf_cc310/include/crys_hash.h" 29 | 30 | class nRFCrypto_Hash 31 | { 32 | public: 33 | nRFCrypto_Hash(void); 34 | 35 | bool begin(CRYS_HASH_OperationMode_t mode); 36 | bool begin(uint32_t mode) 37 | { 38 | return begin ((CRYS_HASH_OperationMode_t) mode); 39 | } 40 | 41 | bool update(uint8_t data[], size_t size); 42 | 43 | uint8_t end(uint32_t result[16]); 44 | uint8_t end(uint8_t result[64]) 45 | { 46 | return end((uint32_t*) result); 47 | } 48 | 49 | private: 50 | CRYS_HASHUserContext_t _context; 51 | uint8_t _digest_len; 52 | }; 53 | 54 | #endif /* NRFCRYPTO_HASH_H_ */ 55 | -------------------------------------------------------------------------------- /src/nRFCrypto_Hmac.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2023 Marcus Schmid (lanaticasylum.de) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "Adafruit_nRFCrypto.h" 26 | 27 | uint8_t digestSize(CRYS_HASH_OperationMode_t mode) { 28 | switch (mode) { 29 | case CRYS_HASH_SHA1_mode: 30 | return CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES; 31 | case CRYS_HASH_SHA224_mode: 32 | return CRYS_HASH_SHA224_DIGEST_SIZE_IN_BYTES; 33 | case CRYS_HASH_SHA256_mode: 34 | return CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES; 35 | case CRYS_HASH_SHA384_mode: 36 | return CRYS_HASH_SHA384_DIGEST_SIZE_IN_BYTES; 37 | case CRYS_HASH_SHA512_mode: 38 | return CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES; 39 | case CRYS_HASH_MD5_mode: 40 | return CRYS_HASH_MD5_DIGEST_SIZE_IN_BYTES; 41 | default: 42 | return 0; 43 | } 44 | } 45 | 46 | nRFCrypto_Hmac::nRFCrypto_Hmac(void) { _digest_size = 0; } 47 | 48 | bool nRFCrypto_Hmac::begin(CRYS_HASH_OperationMode_t mode, uint8_t *key_ptr, 49 | uint16_t keySize) { 50 | _digest_size = digestSize(mode); 51 | VERIFY_ERROR(CRYS_HMAC_Init(&_context, mode, key_ptr, keySize), false); 52 | return true; 53 | } 54 | 55 | bool nRFCrypto_Hmac::update(uint8_t data[], size_t size) { 56 | VERIFY_ERROR(CRYS_HMAC_Update(&_context, data, size), false); 57 | return true; 58 | } 59 | 60 | uint8_t nRFCrypto_Hmac::end(uint32_t result[16]) { 61 | VERIFY_ERROR(CRYS_HMAC_Finish(&_context, result), 0); 62 | return _digest_size; 63 | } 64 | -------------------------------------------------------------------------------- /src/nRFCrypto_Hmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2023 Marcus Schmid (lanaticasylum.de) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef NRFCRYPTO_HMAC_H_ 26 | #define NRFCRYPTO_HMAC_H_ 27 | 28 | #include "nrf_cc310/include/crys_hash.h" 29 | #include "nrf_cc310/include/crys_hmac.h" 30 | 31 | class nRFCrypto_Hmac 32 | { 33 | public: 34 | nRFCrypto_Hmac(void); 35 | 36 | bool begin(CRYS_HASH_OperationMode_t mode, uint8_t *key_ptr, uint16_t keySize); 37 | bool update(uint8_t data[], size_t size); 38 | uint8_t end(uint32_t result[16]); 39 | 40 | private: 41 | CRYS_HMACUserContext_t _context; 42 | uint8_t _digest_size; 43 | }; 44 | 45 | #endif /* NRFCRYPTO_HMAC_H_ */ 46 | -------------------------------------------------------------------------------- /src/nRFCrypto_Random.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "Adafruit_nRFCrypto.h" 26 | 27 | //--------------------------------------------------------------------+ 28 | // MACRO TYPEDEF CONSTANT ENUM DECLARATION 29 | //--------------------------------------------------------------------+ 30 | 31 | 32 | //------------- IMPLEMENTATION -------------// 33 | nRFCrypto_Random::nRFCrypto_Random(void) 34 | { 35 | _begun = false; 36 | } 37 | 38 | bool nRFCrypto_Random::begin(void) 39 | { 40 | // skip if already called begin before 41 | if (_begun) return true; 42 | _begun = true; 43 | 44 | CRYS_RND_WorkBuff_t* workbuf = (CRYS_RND_WorkBuff_t*) rtos_malloc(sizeof(CRYS_RND_WorkBuff_t)); 45 | VERIFY(workbuf); 46 | 47 | uint32_t err = CRYS_RndInit(&_state, workbuf); 48 | rtos_free(workbuf); 49 | 50 | VERIFY_ERROR(err, false); 51 | return true; 52 | } 53 | 54 | void nRFCrypto_Random::end(void) 55 | { 56 | // skipped if not begin-ed 57 | if (!_begun) return; 58 | _begun = false; 59 | 60 | uint32_t err = CRYS_RND_UnInstantiation(&_state); 61 | VERIFY_ERROR(err, ); 62 | } 63 | 64 | CRYS_RND_State_t* nRFCrypto_Random::getContext(void) 65 | { 66 | return &_state; 67 | } 68 | 69 | bool nRFCrypto_Random::addAdditionalInput(uint8_t* input, uint16_t size) 70 | { 71 | VERIFY_ERROR(CRYS_RND_AddAdditionalInput(&_state, input, size), false); 72 | return true; 73 | } 74 | 75 | bool nRFCrypto_Random::reseed(void) 76 | { 77 | CRYS_RND_WorkBuff_t* workbuf = (CRYS_RND_WorkBuff_t*) rtos_malloc(sizeof(CRYS_RND_WorkBuff_t)); 78 | VERIFY(workbuf); 79 | 80 | uint32_t err = CRYS_RND_Reseeding(&_state, workbuf); 81 | rtos_free(workbuf); 82 | 83 | VERIFY_ERROR(err, false); 84 | return true; 85 | } 86 | 87 | bool nRFCrypto_Random::generate(uint8_t* buf, uint16_t bufsize) 88 | { 89 | VERIFY_ERROR(CRYS_RND_GenerateVector(&_state, bufsize, buf), false); 90 | return true; 91 | } 92 | 93 | bool nRFCrypto_Random::generateInRange(uint8_t* buf, uint32_t bitsize, uint8_t* max) 94 | { 95 | VERIFY_ERROR(CRYS_RND_GenerateVectorInRange(&_state, CRYS_RND_GenerateVector, bitsize, max, buf), false); 96 | return true; 97 | } 98 | -------------------------------------------------------------------------------- /src/nRFCrypto_Random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef NRFCRYPTO_RANDOM_H_ 26 | #define NRFCRYPTO_RANDOM_H_ 27 | 28 | #include "nrf_cc310/include/crys_rnd.h" 29 | 30 | class nRFCrypto_Random 31 | { 32 | public: 33 | nRFCrypto_Random(void); 34 | 35 | bool begin(void); 36 | void end(void); 37 | 38 | CRYS_RND_State_t* getContext(void); 39 | 40 | bool addAdditionalInput(uint8_t* input, uint16_t size); 41 | bool reseed(void); 42 | bool generate(uint8_t* buf, uint16_t count); 43 | bool generateInRange(uint8_t* buf, uint32_t bitsize, uint8_t* max = NULL); 44 | 45 | // enterKAtMode() DisableKatMoe() 46 | 47 | private: 48 | CRYS_RND_State_t _state; 49 | bool _begun; 50 | }; 51 | 52 | #endif /* NRFCRYPTO_RANDOM_H_ */ 53 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_chacha_poly_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_CHACHA_POLY_ERROR_H 37 | #define CRYS_CHACHA_POLY_ERROR_H 38 | 39 | 40 | #include "crys_error.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /*! 48 | @file 49 | @brief This module contains the definitions of the CRYS CHACHA POLY errors. 50 | @defgroup crys_chacha_poly_error CryptoCell CHACHA POLY specific errors 51 | @{ 52 | @ingroup crys_chacha_poly 53 | */ 54 | 55 | 56 | 57 | /************************ Defines ******************************/ 58 | 59 | /*! The CRYS CHACHA POLY module errors base address - 0x00F02400. */ 60 | /*! Invalid Additional data. */ 61 | #define CRYS_CHACHA_POLY_ADATA_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x01UL) 62 | /*! Invalid input data. */ 63 | #define CRYS_CHACHA_POLY_DATA_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x02UL) 64 | /*! Illegal encryption mode. */ 65 | #define CRYS_CHACHA_POLY_ENC_MODE_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x03UL) 66 | /*! Illegal data size. */ 67 | #define CRYS_CHACHA_POLY_DATA_SIZE_INVALID_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x04UL) 68 | /*! Key generation error. */ 69 | #define CRYS_CHACHA_POLY_GEN_KEY_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x05UL) 70 | /*! CHACHA Key generation error. */ 71 | #define CRYS_CHACHA_POLY_ENCRYPTION_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x06UL) 72 | /*! Authentication error. */ 73 | #define CRYS_CHACHA_POLY_AUTH_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x07UL) 74 | /*! MAC comparison error. */ 75 | #define CRYS_CHACHA_POLY_MAC_ERROR (CRYS_CHACHA_POLY_MODULE_ERROR_BASE + 0x08UL) 76 | 77 | /************************ Enums ********************************/ 78 | 79 | /************************ Typedefs ****************************/ 80 | 81 | /************************ Structs *****************************/ 82 | 83 | /************************ Public Variables *********************/ 84 | 85 | /************************ Public Functions *********************/ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | /** 91 | @} 92 | */ 93 | #endif 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_common_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef CRYS_COMMON_ERROR_H 38 | #define CRYS_COMMON_ERROR_H 39 | 40 | #include "crys_error.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | 48 | /************************ Defines ******************************/ 49 | 50 | /* CRYS COMMON module errors. Base address - 0x00F00D00 */ 51 | 52 | #define CRYS_COMMON_INIT_HW_SEM_CREATION_FAILURE (CRYS_COMMON_MODULE_ERROR_BASE + 0x0UL) 53 | #define CRYS_COMMON_DATA_IN_POINTER_INVALID_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x4UL) 54 | #define CRYS_COMMON_DATA_SIZE_ILLEGAL (CRYS_COMMON_MODULE_ERROR_BASE + 0x5UL) 55 | #define CRYS_COMMON_DATA_OUT_DATA_IN_OVERLAP_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x6UL) 56 | #define CRYS_COMMON_DATA_OUT_POINTER_INVALID_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x7UL) 57 | #define CRYS_COMMON_OUTPUT_BUFF_SIZE_ILLEGAL (CRYS_COMMON_MODULE_ERROR_BASE + 0x9UL) 58 | 59 | #define CRYS_COMMON_TST_UTIL_CHUNK_SIZE_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x10UL) 60 | #define CRYS_COMMON_ERROR_IN_SAVING_LLI_DATA_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x11UL) 61 | 62 | 63 | #define CRYS_COMMON_TST_UTIL_LLI_ENTRY_SIZE_TOO_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x12UL) 64 | #define CRYS_COMMON_TST_CSI_DATA_SIZE_EXCEED_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x13UL) 65 | #define CRYS_COMMON_TST_CSI_MODULE_ID_OUT_OF_RANGE (CRYS_COMMON_MODULE_ERROR_BASE + 0x14UL) 66 | #define CRYS_COMMON_TST_CSI_MEMORY_MAPPING_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x15UL) 67 | 68 | #define CRYS_COMMON_TERM_HW_SEM_DELETE_FAILURE (CRYS_COMMON_MODULE_ERROR_BASE + 0x16UL) 69 | 70 | #define CRYS_COMMON_TST_UTIL_NOT_INTEGER_CHAR_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x17UL) 71 | #define CRYS_COMMON_TST_UTIL_BUFFER_IS_SMALL_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x18UL) 72 | #define CRYS_COMMON_POINTER_NOT_ALIGNED_ERROR (CRYS_COMMON_MODULE_ERROR_BASE + 0x19UL) 73 | 74 | 75 | /************************ Enums ********************************/ 76 | 77 | 78 | /************************ Typedefs ****************************/ 79 | 80 | 81 | /************************ Structs ******************************/ 82 | 83 | 84 | /************************ Public Variables **********************/ 85 | 86 | 87 | /************************ Public Functions **********************/ 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_ecpki_dh.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef CRYS_ECPKI_DH_H 38 | #define CRYS_ECPKI_DH_H 39 | 40 | /*! @file 41 | @brief Defines the API that supports EC Diffie-Hellman shared secret value derivation primitives. 42 | @defgroup crys_ecpki_dh CryptoCell ECC Diffie-Hellman APIs 43 | @{ 44 | @ingroup cryptocell_ecpki 45 | */ 46 | 47 | 48 | #include "crys_ecpki_types.h" 49 | #include "crys_ecpki_error.h" 50 | 51 | #ifdef __cplusplus 52 | extern "C" 53 | { 54 | #endif 55 | 56 | /*********************************************************************** 57 | * CRYS_ECDH_SVDP_DH function * 58 | ***********************************************************************/ 59 | /*! 60 | @brief Creates the shared secret value according to [IEEE1363, ANS X9.63]: 61 | 62 |
  1. Checks input-parameter pointers and EC Domain in public and private 63 | keys.
  2. 64 |
  3. Derives the partner public key and calls the EcWrstDhDeriveSharedSecret 65 | function, which performs EC SVDP operations.
66 | \note The term "User" 67 | refers to any party that calculates a shared secret value using this primitive. 68 | The term "Partner" refers to any other party of shared secret value calculation. 69 | Partner's public key shall be validated before using in this primitive. 70 | 71 | @return CRYS_OK on success. 72 | @return A non-zero value on failure as defined crys_ecpki_error.h. 73 | */ 74 | CIMPORT_C CRYSError_t CRYS_ECDH_SVDP_DH( 75 | CRYS_ECPKI_UserPublKey_t *PartnerPublKey_ptr, /*!< [in] Pointer to a partner public key. */ 76 | CRYS_ECPKI_UserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to a user private key. */ 77 | uint8_t *SharedSecretValue_ptr, /*!< [out] Pointer to an output buffer that will contain the shared 78 | secret value. */ 79 | uint32_t *SharedSecrValSize_ptr, /*!< [in/out] Pointer to the size of user-passed buffer (in) and 80 | actual size of output of calculated shared secret value 81 | (out). */ 82 | CRYS_ECDH_TempData_t *TempBuff_ptr /*!< [in] Pointer to a temporary buffer. */); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | /** 88 | @} 89 | */ 90 | #endif 91 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_ecpki_domain.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef CRYS_ECPKI_DOMAIN_H 38 | #define CRYS_ECPKI_DOMAIN_H 39 | 40 | 41 | /*! 42 | @file 43 | @brief Defines the ecpki build domain API. 44 | @defgroup crys_ecpki_domain CryptoCell ECC domain APIs 45 | @{ 46 | @ingroup cryptocell_ecpki 47 | */ 48 | 49 | 50 | #include "crys_error.h" 51 | #include "crys_ecpki_types.h" 52 | 53 | #ifdef __cplusplus 54 | extern "C" 55 | { 56 | #endif 57 | 58 | 59 | 60 | 61 | /********************************************************************************** 62 | * CRYS_ECPKI_GetEcDomain function * 63 | **********************************************************************************/ 64 | 65 | /*! 66 | * @brief The function returns a pointer to an ECDSA saved domain (one of the supported domains). 67 | * 68 | * @return Domain pointer on success. 69 | * @return NULL on failure. 70 | */ 71 | 72 | const CRYS_ECPKI_Domain_t *CRYS_ECPKI_GetEcDomain(CRYS_ECPKI_DomainID_t domainId /*!< [in] Index of one of the domain Id (must be one of the supported domains). */); 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | /** 78 | @} 79 | */ 80 | #endif 81 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_ecpki_kg.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef CRYS_ECPKI_KG_H 38 | #define CRYS_ECPKI_KG_H 39 | 40 | /*! @file 41 | @brief Defines the API for generation of ECC private and public keys. 42 | @defgroup crys_ecpki_kg CryptoCell ECC Key Generation APIs 43 | @{ 44 | @ingroup cryptocell_ecpki 45 | */ 46 | 47 | 48 | #include "crys_error.h" 49 | #include "crys_rnd.h" 50 | #include "crys_ecpki_types.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C" 54 | { 55 | #endif 56 | 57 | /***************** CRYS_ECPKI_GenKeyPair function **********************/ 58 | /*! 59 | @brief Generates a pair of private and public keys in internal representation according to [ANS X9.62]. 60 | 61 | @return CRYS_OK on success. 62 | @return A non-zero value on failure as defined crys_ecpki_error.h or crys_rnd_error.h 63 | */ 64 | CIMPORT_C CRYSError_t CRYS_ECPKI_GenKeyPair( 65 | void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */ 66 | SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */ 67 | const CRYS_ECPKI_Domain_t *pDomain, /*!< [in] Pointer to EC domain (curve). */ 68 | CRYS_ECPKI_UserPrivKey_t *pUserPrivKey, /*!< [out] Pointer to the private key structure. This structure is used as input to the 69 | ECPKI cryptographic primitives. */ 70 | CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [out] Pointer to the public key structure. This structure is used as input to the 71 | ECPKI cryptographic primitives. */ 72 | CRYS_ECPKI_KG_TempData_t *pTempData, /*!< [in] Temporary buffers for internal use, defined in ::CRYS_ECPKI_KG_TempData_t. */ 73 | CRYS_ECPKI_KG_FipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */ 74 | ); 75 | 76 | 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | /** 82 | @} 83 | */ 84 | #endif 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_hash_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_HASH_DEFS_H 37 | #define CRYS_HASH_DEFS_H 38 | 39 | /*! 40 | @file 41 | @brief This file contains HASH definitions. 42 | @defgroup crys_hash_defs CryptoCell Hash definitions 43 | @{ 44 | @ingroup crys_hash 45 | */ 46 | 47 | #ifdef __cplusplus 48 | extern "C" 49 | { 50 | #endif 51 | 52 | 53 | /************************ Defines ******************************/ 54 | 55 | /*! The size of user's context prototype (see ::CRYS_HASHUserContext_t) in words. */ 56 | #define CRYS_HASH_USER_CTX_SIZE_IN_WORDS 60 57 | 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | /** 64 | @} 65 | */ 66 | #endif 67 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_hash_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | 38 | #ifndef CRYS_HASH_ERROR_H 39 | #define CRYS_HASH_ERROR_H 40 | 41 | 42 | #include "crys_error.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" 46 | { 47 | #endif 48 | 49 | /*! 50 | @file 51 | @brief This module contains the definitions of the CRYS HASH errors. 52 | @defgroup crys_hash_error CryptoCell HASH specific errors 53 | @{ 54 | @ingroup crys_hash 55 | */ 56 | 57 | 58 | 59 | 60 | /************************ Defines ******************************/ 61 | /*! HASH module on the CRYS layer base address - 0x00F00200*/ 62 | /* The CRYS HASH module errors */ 63 | /*! Illegal context pointer. */ 64 | #define CRYS_HASH_INVALID_USER_CONTEXT_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x0UL) 65 | /*! Illegal operation mode. */ 66 | #define CRYS_HASH_ILLEGAL_OPERATION_MODE_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x1UL) 67 | /*! Context is corrupted. */ 68 | #define CRYS_HASH_USER_CONTEXT_CORRUPTED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x2UL) 69 | /*! Illegal data in pointer. */ 70 | #define CRYS_HASH_DATA_IN_POINTER_INVALID_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x3UL) 71 | /*! Illegal data in size. */ 72 | #define CRYS_HASH_DATA_SIZE_ILLEGAL (CRYS_HASH_MODULE_ERROR_BASE + 0x4UL) 73 | /*! Illegal result buffer pointer. */ 74 | #define CRYS_HASH_INVALID_RESULT_BUFFER_POINTER_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0x5UL) 75 | /*! Last block was already processed (may happen if previous block was not a multiple of block size). */ 76 | #define CRYS_HASH_LAST_BLOCK_ALREADY_PROCESSED_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xCUL) 77 | /*! Illegal parameter. */ 78 | #define CRYS_HASH_ILLEGAL_PARAMS_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xDUL) 79 | /*! Illegal context size. */ 80 | #define CRYS_HASH_CTX_SIZES_ERROR (CRYS_HASH_MODULE_ERROR_BASE + 0xEUL) 81 | /*! HASH is not supported. */ 82 | #define CRYS_HASH_IS_NOT_SUPPORTED (CRYS_HASH_MODULE_ERROR_BASE + 0xFUL) 83 | 84 | 85 | 86 | /************************ Enums ********************************/ 87 | 88 | 89 | /************************ Typedefs ****************************/ 90 | 91 | 92 | /************************ Structs ******************************/ 93 | 94 | 95 | /************************ Public Variables **********************/ 96 | 97 | 98 | /************************ Public Functions **********************/ 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | /** 104 | @} 105 | */ 106 | #endif 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_hkdf_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_HKDF_ERROR_H 37 | #define CRYS_HKDF_ERROR_H 38 | 39 | #include "crys_error.h" 40 | 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /*! 48 | @file 49 | @brief This module contains the definitions of the CRYS HKDF errors. 50 | @defgroup crys_hkdf_error HMAC Key Derivation specific errors 51 | @{ 52 | @ingroup crys_hkdf 53 | */ 54 | 55 | 56 | /************************ Defines *******************************/ 57 | 58 | /*! CryptoCell HKDF module errors / base address - 0x00F01100. */ 59 | /*! Invalid argument. */ 60 | #define CRYS_HKDF_INVALID_ARGUMENT_POINTER_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x0UL) 61 | /*! Invalid argument size. */ 62 | #define CRYS_HKDF_INVALID_ARGUMENT_SIZE_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x1UL) 63 | /*! Illegal hash mode. */ 64 | #define CRYS_HKDF_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_HKDF_MODULE_ERROR_BASE + 0x3UL) 65 | /*! HKDF not supported. */ 66 | #define CRYS_HKDF_IS_NOT_SUPPORTED (CRYS_HKDF_MODULE_ERROR_BASE + 0xFFUL) 67 | 68 | /************************ Enums *********************************/ 69 | 70 | /************************ Typedefs *****************************/ 71 | 72 | /************************ Structs ******************************/ 73 | 74 | /************************ Public Variables **********************/ 75 | 76 | /************************ Public Functions **********************/ 77 | 78 | 79 | 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | /** 85 | @} 86 | */ 87 | #endif 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_hmac_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_HMAC_DEFS_H 37 | #define CRYS_HMAC_DEFS_H 38 | 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /*! 46 | @file 47 | @brief This file contains HMAC definitions. 48 | @defgroup crys_hmac_defs CryptoCell Hmac definitions 49 | @{ 50 | @ingroup crys_hmac 51 | */ 52 | 53 | /************************ Defines ******************************/ 54 | /*! The size of user's context prototype (see ::CRYS_HMACUserContext_t) in words. */ 55 | #define CRYS_HMAC_USER_CTX_SIZE_IN_WORDS 94 56 | 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | /** 62 | @} 63 | */ 64 | #endif 65 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_kdf_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_KDF_ERROR_H 37 | #define CRYS_KDF_ERROR_H 38 | 39 | #include "crys_error.h" 40 | 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /*! 48 | @file 49 | @brief This module contains the definitions of the CRYS KDF errors. 50 | @defgroup crys_kdf_error CryptoCell Key Derivation specific errors 51 | @{ 52 | @ingroup crys_kdf 53 | */ 54 | 55 | 56 | /************************ Defines *******************************/ 57 | 58 | /*! The CRYS KDF module errors / base address - 0x00F01100*/ 59 | /*! Illegal input pointer. */ 60 | #define CRYS_KDF_INVALID_ARGUMENT_POINTER_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x0UL) 61 | /*! Illegal input size. */ 62 | #define CRYS_KDF_INVALID_ARGUMENT_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x1UL) 63 | /*! Illegal operation mode. */ 64 | #define CRYS_KDF_INVALID_ARGUMENT_OPERATION_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x2UL) 65 | /*! Illegal hash mode. */ 66 | #define CRYS_KDF_INVALID_ARGUMENT_HASH_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x3UL) 67 | /*! Illegal key derivation mode. */ 68 | #define CRYS_KDF_INVALID_KEY_DERIVATION_MODE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x4UL) 69 | /*! Illegal shared secret value size. */ 70 | #define CRYS_KDF_INVALID_SHARED_SECRET_VALUE_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x5UL) 71 | /*! Illegal otherInfo size. */ 72 | #define CRYS_KDF_INVALID_OTHER_INFO_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x6UL) 73 | /*! Illegal key data size. */ 74 | #define CRYS_KDF_INVALID_KEYING_DATA_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x7UL) 75 | /*! Illegal algorithm ID pointer. */ 76 | #define CRYS_KDF_INVALID_ALGORITHM_ID_POINTER_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x8UL) 77 | /*! Illegal algorithm ID size. */ 78 | #define CRYS_KDF_INVALID_ALGORITHM_ID_SIZE_ERROR (CRYS_KDF_MODULE_ERROR_BASE + 0x9UL) 79 | /*! KDF is not supproted. */ 80 | #define CRYS_KDF_IS_NOT_SUPPORTED (CRYS_KDF_MODULE_ERROR_BASE + 0xFFUL) 81 | 82 | /************************ Enums *********************************/ 83 | 84 | /************************ Typedefs *****************************/ 85 | 86 | /************************ Structs ******************************/ 87 | 88 | /************************ Public Variables **********************/ 89 | 90 | /************************ Public Functions **********************/ 91 | 92 | 93 | 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | /** 99 | @} 100 | */ 101 | #endif 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_poly.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | /*! 37 | @file 38 | @brief This file contains all of the enums and definitions that are used for the 39 | CRYS POLY APIs, as well as the APIs themselves. 40 | @defgroup crys_poly CryptoCell POLY APIs 41 | @{ 42 | @ingroup cryptocell_api 43 | 44 | */ 45 | #ifndef CRYS_POLY_H 46 | #define CRYS_POLY_H 47 | 48 | 49 | #include "ssi_pal_types.h" 50 | #include "crys_error.h" 51 | 52 | 53 | #ifdef __cplusplus 54 | extern "C" 55 | { 56 | #endif 57 | 58 | /************************ Defines ******************************/ 59 | /*! POLY KEY size in words. */ 60 | #define CRYS_POLY_KEY_SIZE_IN_WORDS 8 61 | /*! POLY KEY size in bytes. */ 62 | #define CRYS_POLY_KEY_SIZE_IN_BYTES (CRYS_POLY_KEY_SIZE_IN_WORDS*SASI_32BIT_WORD_SIZE) 63 | 64 | /*! POLY MAC size in words. */ 65 | #define CRYS_POLY_MAC_SIZE_IN_WORDS 4 66 | /*! POLY MAC size in bytes. */ 67 | #define CRYS_POLY_MAC_SIZE_IN_BYTES (CRYS_POLY_MAC_SIZE_IN_WORDS*SASI_32BIT_WORD_SIZE) 68 | 69 | /************************ Typedefs ****************************/ 70 | 71 | /*! CHACHA MAC buffer definition. */ 72 | typedef uint32_t CRYS_POLY_Mac_t[CRYS_POLY_MAC_SIZE_IN_WORDS]; 73 | 74 | /*! CHACHA key buffer definition. */ 75 | typedef uint32_t CRYS_POLY_Key_t[CRYS_POLY_KEY_SIZE_IN_WORDS]; 76 | 77 | /************************ Public Functions **********************/ 78 | 79 | /****************************************************************************************************/ 80 | /*! 81 | @brief This function is used to perform the POLY MAC Calculation. 82 | 83 | @return CRYS_OK on success. 84 | @return A non-zero value on failure as defined crys_poly_error.h. 85 | */ 86 | CIMPORT_C CRYSError_t CRYS_POLY( 87 | CRYS_POLY_Key_t pKey, /*!< [in] A pointer to the user's key buffer. */ 88 | uint8_t *pDataIn, /*!< [in] A pointer to the buffer of the input data to the CHACHA. 89 | must not be null. */ 90 | size_t dataInSize, /*!< [in] The size of the input data. must not be 0. */ 91 | CRYS_POLY_Mac_t macRes /*!< [in/out] Pointer to the MAC result buffer.*/ 92 | ); 93 | 94 | 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | /** 100 | @} 101 | */ 102 | #endif /* #ifndef CRYS_POLY_H */ 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_poly_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_POLY_ERROR_H 37 | #define CRYS_POLY_ERROR_H 38 | 39 | 40 | #include "crys_error.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /*! 48 | @file 49 | @brief This module contains the definitions of the CRYS POLY errors. 50 | @defgroup crys_poly_error CryptoCell POLY specific errors 51 | @{ 52 | @ingroup crys_poly 53 | */ 54 | 55 | 56 | /************************ Defines ******************************/ 57 | 58 | /*! The CRYS POLY module errors base address - 0x00F02500 */ 59 | /*! Invalid key. */ 60 | #define CRYS_POLY_KEY_INVALID_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x01UL) 61 | /*! Invalid input data. */ 62 | #define CRYS_POLY_DATA_INVALID_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x02UL) 63 | /*! Illegal input data size. */ 64 | #define CRYS_POLY_DATA_SIZE_INVALID_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x03UL) 65 | /*! MAC calculation error. */ 66 | #define CRYS_POLY_MAC_CALCULATION_ERROR (CRYS_POLY_MODULE_ERROR_BASE + 0x04UL) 67 | 68 | /************************ Enums ********************************/ 69 | 70 | /************************ Typedefs ****************************/ 71 | 72 | /************************ Structs *****************************/ 73 | 74 | /************************ Public Variables *********************/ 75 | 76 | /************************ Public Functions *********************/ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | 83 | /** 84 | @} 85 | */ 86 | 87 | #endif 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/crys_srp_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_SRP_ERROR_H 37 | #define CRYS_SRP_ERROR_H 38 | 39 | 40 | #include "crys_error.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /*! 48 | @file 49 | @brief This module contains the definitions of the CRYS SRP errors. 50 | @defgroup crys_srp_error CryptoCell SRP specific errors 51 | @{ 52 | @ingroup crys_srp 53 | */ 54 | 55 | 56 | 57 | /************************ Defines ******************************/ 58 | 59 | /*! The CRYS SRP module errors base address - 0x00F02600. */ 60 | /*! Illegal parameter. */ 61 | #define CRYS_SRP_PARAM_INVALID_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x01UL) 62 | /*! Illegal modulus size . */ 63 | #define CRYS_SRP_MOD_SIZE_INVALID_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x02UL) 64 | /*! Illegal state (uninitialized) . */ 65 | #define CRYS_SRP_STATE_UNINITIALIZED_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x03UL) 66 | /*! Result validation error. */ 67 | #define CRYS_SRP_RESULT_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x04UL) 68 | /*! Invalid parameter. */ 69 | #define CRYS_SRP_PARAM_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x05UL) 70 | /*! Internal PKI error */ 71 | #define CRYS_SRP_PKI_INTERNAL_ERROR (CRYS_SRP_MODULE_ERROR_BASE + 0x06UL) 72 | 73 | /************************ Enums ********************************/ 74 | 75 | /************************ Typedefs ****************************/ 76 | 77 | /************************ Structs *****************************/ 78 | 79 | /************************ Public Variables *********************/ 80 | 81 | /************************ Public Functions *********************/ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | /** 87 | @} 88 | */ 89 | #endif 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/dx_reg_base_host.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | #ifndef __DX_REG_BASE_HOST_H__ 36 | #define __DX_REG_BASE_HOST_H__ 37 | 38 | /* Identify platform: Xilinx Zynq7000 ZC706 */ 39 | #define DX_PLAT_ZYNQ7000 1 40 | #define DX_PLAT_ZYNQ7000_ZC706 1 41 | 42 | /* SEP core clock frequency in MHz */ 43 | #define DX_SEP_FREQ_MHZ 64 44 | #if defined(CRYPTOCELL_ARCH_BASE_ADDRESS) 45 | #define DX_BASE_CC CRYPTOCELL_ARCH_BASE_ADDRESS 46 | #else 47 | #error Please set CRYPTOCELL_ARCH_BASE_ADDRESS to a non-negative number 48 | #endif 49 | 50 | #define DX_BASE_ENV_REGS 0x40008000 51 | #define DX_BASE_ENV_CC_MEMORIES 0x40008000 52 | #define DX_BASE_ENV_FLASH 0x40008700 53 | #define DX_BASE_ENV_PERF_RAM 0x40009000 54 | 55 | #define DX_BASE_HOST_RGF 0x0UL 56 | #define DX_BASE_CRY_KERNEL 0x0UL 57 | #define DX_BASE_ROM 0x40000000 58 | 59 | #define DX_BASE_RNG 0x0000UL 60 | #endif /*__DX_REG_BASE_HOST_H__*/ 61 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/sns_silib.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | /*! 37 | @file 38 | @brief This file contains all of the enums and definitions that are used for the 39 | CryptoCell Lib init and finish APIs, as well as the APIs themselves. 40 | @defgroup sns_silib CryptoCell library basic APIs 41 | @{ 42 | @ingroup cryptocell_api 43 | 44 | */ 45 | 46 | #ifndef __SNS_SILIB_H__ 47 | #define __SNS_SILIB_H__ 48 | 49 | #include "ssi_pal_types.h" 50 | #include "crys_rnd.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C" 54 | { 55 | #endif 56 | 57 | /*! Definitions for error returns from SaSi_LibInit or SaSi_LibFini functions. */ 58 | typedef enum { 59 | SA_SILIB_RET_OK = 0, /*!< Success defintion.*/ 60 | SA_SILIB_RET_EINVAL_CTX_PTR, /*!< Illegal context pointer.*/ 61 | SA_SILIB_RET_EINVAL_WORK_BUF_PTR, /*!< Illegal work buffer pointer.*/ 62 | SA_SILIB_RET_HAL, /*!< Error returned from HAL layer.*/ 63 | SA_SILIB_RET_PAL, /*!< Error returned from PAL layer.*/ 64 | SA_SILIB_RET_EINVAL_HW_VERSION, /*!< Invalid HW version. */ 65 | SA_SILIB_RET_EINVAL_HW_SIGNATURE, /*!< Invalid HW signature. */ 66 | SA_SILIB_RESERVE32B = 0x7FFFFFFFL /*!< Reserved.*/ 67 | } SA_SilibRetCode_t; 68 | 69 | 70 | /*! Internal defintion for the product register. */ 71 | #define DX_VERSION_PRODUCT_BIT_SHIFT 0x18UL 72 | /*! Internal defintion for the product register size. */ 73 | #define DX_VERSION_PRODUCT_BIT_SIZE 0x8UL 74 | 75 | 76 | 77 | /*! 78 | @brief This function Perform global initialization of the ARM CryptoCell 3xx runtime library; 79 | it must be called once per ARM CryptoCell for 3xx cold boot cycle. 80 | 81 | \note The Mutexes, if used, are initialized by this API. Therefore, unlike the other APIs in the library, 82 | this API is not thread-safe. 83 | @return SA_SILIB_RET_OK on success. 84 | @return A non-zero value in case of failure. 85 | */ 86 | SA_SilibRetCode_t SaSi_LibInit(void); 87 | 88 | /*! 89 | @brief This function finalize the library operations. It frees the associated resources (mutexes) and call hal and pal terminate functions. 90 | in case of active instansiation - one must call CRYS_RND_UnInstantiation to clean the rnd state. 91 | */ 92 | void SaSi_LibFini(void); 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | /** 98 | @} 99 | */ 100 | #endif /*__DX_CCLIB_H__*/ 101 | 102 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_aes_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | /*! 37 | @file 38 | @brief This file contains definitions that are used for the ARM CryptoCell 3xx version of the CryptoCell AES APIs. 39 | @defgroup ssi_aes_defs CryptoCell AES definitions 40 | @{ 41 | @ingroup ssi_aes 42 | 43 | */ 44 | 45 | #ifndef SSI_AES_DEFS_H 46 | #define SSI_AES_DEFS_H 47 | 48 | #include "ssi_pal_types.h" 49 | 50 | 51 | #ifdef __cplusplus 52 | extern "C" 53 | { 54 | #endif 55 | 56 | /************************ Defines ******************************/ 57 | 58 | /*! The size of the user's context prototype (see ::SaSiAesUserContext_t) in words. */ 59 | #define SASI_AES_USER_CTX_SIZE_IN_WORDS (4+4+7+4) 60 | 61 | /*! The AES block size in words. */ 62 | #define SASI_AES_BLOCK_SIZE_IN_WORDS 4 63 | /*! The AES block size in bytes. */ 64 | #define SASI_AES_BLOCK_SIZE_IN_BYTES (SASI_AES_BLOCK_SIZE_IN_WORDS * sizeof(uint32_t)) 65 | 66 | /*! The size of the IV buffer in words. */ 67 | #define SASI_AES_IV_SIZE_IN_WORDS SASI_AES_BLOCK_SIZE_IN_WORDS 68 | /*! The size of the IV buffer in bytes. */ 69 | #define SASI_AES_IV_SIZE_IN_BYTES (SASI_AES_IV_SIZE_IN_WORDS * sizeof(uint32_t)) 70 | 71 | /*! The maximum size of the AES KEY in words. */ 72 | #define SASI_AES_KEY_MAX_SIZE_IN_WORDS 4 73 | /*! The maximum size of the AES KEY in bytes. */ 74 | #define SASI_AES_KEY_MAX_SIZE_IN_BYTES (SASI_AES_KEY_MAX_SIZE_IN_WORDS * sizeof(uint32_t)) 75 | 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | /** 81 | @} 82 | */ 83 | #endif /* #ifndef SSI_AES_DEFS_H */ 84 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_bitops.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | /*! 37 | * \file ssi_bitops.h 38 | * Bit fields operations macros. 39 | */ 40 | #ifndef _SSI_BITOPS_H_ 41 | #define _SSI_BITOPS_H_ 42 | 43 | #define BITMASK(mask_size) (((mask_size) < 32) ? \ 44 | ((1UL << (mask_size)) - 1) : 0xFFFFFFFFUL) 45 | #define BITMASK_AT(mask_size, mask_offset) (BITMASK(mask_size) << (mask_offset)) 46 | 47 | #define BITFIELD_GET(word, bit_offset, bit_size) \ 48 | (((word) >> (bit_offset)) & BITMASK(bit_size)) 49 | #define BITFIELD_SET(word, bit_offset, bit_size, new_val) do { \ 50 | word = ((word) & ~BITMASK_AT(bit_size, bit_offset)) | \ 51 | (((new_val) & BITMASK(bit_size)) << (bit_offset)); \ 52 | } while (0) 53 | 54 | /* Is val aligned to "align" ("align" must be power of 2) */ 55 | #ifndef IS_ALIGNED 56 | #define IS_ALIGNED(val, align) \ 57 | (((uint32_t)(val) & ((align) - 1)) == 0) 58 | #endif 59 | 60 | #define SWAP_ENDIAN(word) \ 61 | (((word) >> 24) | (((word) & 0x00FF0000) >> 8) | \ 62 | (((word) & 0x0000FF00) << 8) | (((word) & 0x000000FF) << 24)) 63 | 64 | #ifdef BIG__ENDIAN 65 | #define SWAP_TO_LE(word) SWAP_ENDIAN(word) 66 | #define SWAP_TO_BE(word) word 67 | #else 68 | #define SWAP_TO_LE(word) word 69 | #define SWAP_TO_BE(word) SWAP_ENDIAN(word) 70 | #endif 71 | 72 | 73 | 74 | /* Is val a multiple of "mult" ("mult" must be power of 2) */ 75 | #define IS_MULT(val, mult) \ 76 | (((val) & ((mult) - 1)) == 0) 77 | 78 | #define IS_NULL_ADDR(adr) \ 79 | (!(adr)) 80 | 81 | #endif /*_SSI_BITOPS_H_*/ 82 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_abort.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_PAL_ABORT_H 37 | #define _SSI_PAL_ABORT_H 38 | 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /*---------------------------- 46 | PUBLIC FUNCTIONS 47 | -----------------------------------*/ 48 | 49 | /*! 50 | @defgroup ssi_pal CryptoCell PAL APIs 51 | @{ 52 | @ingroup cryptocell_api 53 | @brief This group is the PAL root group 54 | @} 55 | 56 | @file 57 | @brief This file contains definitions for PAL Abort API. 58 | @defgroup ssi_pal_abort CryptoCell PAL abort APIs 59 | @{ 60 | @ingroup ssi_pal 61 | 62 | */ 63 | 64 | /*! 65 | This function performs the "Abort" operation, should be implemented according to platform and OS. 66 | */ 67 | 68 | void SaSi_PalAbort(const char *msg); 69 | /** 70 | @} 71 | */ 72 | 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_barrier.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef _SSI_PAL_BARRIER_H 38 | #define _SSI_PAL_BARRIER_H 39 | 40 | /*! 41 | @file 42 | @brief This file contains the definitions and APIs for memory barrier implementation. 43 | This is a place holder for platform specific memory barrier implementation 44 | The secure core driver should include a memory barrier before and after the last word of the descriptor 45 | to allow correct order between the words and different descriptors. 46 | @defgroup ssi_pal_barrier CryptoCell PAL memory Barrier APIs 47 | @{ 48 | @ingroup ssi_pal 49 | 50 | */ 51 | 52 | /*! 53 | * This MACRO is responsible to put the memory barrier after the write operation. 54 | * 55 | * @return None 56 | */ 57 | 58 | void SaSi_PalWmb(void); 59 | 60 | /*! 61 | * This MACRO is responsible to put the memory barrier before the read operation. 62 | * 63 | * @return None 64 | */ 65 | void SaSi_PalRmb(void); 66 | 67 | /** 68 | @} 69 | */ 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_dma_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | /*! 38 | @file 39 | @brief This file contains the platform dependent DMA definitions. 40 | @defgroup ssi_pal_dma_defs CryptoCell PAL DMA specific definitions 41 | @{ 42 | @ingroup ssi_pal 43 | */ 44 | 45 | #ifndef _SSI_PAL_DMA_DEFS_H 46 | #define _SSI_PAL_DMA_DEFS_H 47 | 48 | 49 | #ifdef __cplusplus 50 | extern "C" 51 | { 52 | #endif 53 | 54 | /*! Definition for DMA buffer handle.*/ 55 | typedef void * SaSi_PalDmaBufferHandle; 56 | 57 | /*! DMA directions configuration */ 58 | typedef enum { 59 | SASI_PAL_DMA_DIR_NONE = 0, /*!< No direction. */ 60 | SASI_PAL_DMA_DIR_TO_DEVICE = 1, /*!< The original buffer is the input to the operation, and should be copied/mapped to a temp buffer, 61 | prior to activating the HW on the temp buffer. */ 62 | SASI_PAL_DMA_DIR_FROM_DEVICE = 2, /*!< The temp buffer holds the output of the HW, and this API should copy/map it to the original output buffer.*/ 63 | SASI_PAL_DMA_DIR_BI_DIRECTION = 3, /*!< Used when the result is written over the original data at the same address. should be treated as 1 & 2.*/ 64 | SASI_PAL_DMA_DIR_MAX, /*!< Maximal DMA directions options. */ 65 | SASI_PAL_DMA_DIR_RESERVE32 = 0x7FFFFFFF /*!< Reserved.*/ 66 | }SaSi_PalDmaBufferDirection_t; 67 | 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | /** 73 | @} 74 | */ 75 | #endif 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_dma_plat.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | 38 | #ifndef _SSI_PAL_DMA_PLAT_H 39 | #define _SSI_PAL_DMA_PLAT_H 40 | 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" 45 | { 46 | #endif 47 | 48 | /** 49 | * @brief stub function, the function should initialize the DMA mapping of the platform (if needed) 50 | * 51 | * @param[in] buffSize - buffer size in Bytes 52 | * @param[in] physBuffAddr - physical start address of the memory to map 53 | * 54 | * @return Virtual start address of contiguous memory 55 | */ 56 | extern uint32_t SaSi_PalDmaInit(uint32_t buffSize, 57 | uint32_t physBuffAddr); 58 | 59 | /** 60 | * @brief free system resources created in PD_PAL_DmaInit() 61 | * 62 | * 63 | * @return void 64 | */ 65 | extern void SaSi_PalDmaTerminate(void); 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_PAL_ERROR_H 37 | #define _SSI_PAL_ERROR_H 38 | 39 | /*! 40 | @file 41 | @brief This file contains the platform dependent error definitions. 42 | @defgroup ssi_pal_error CryptoCell PAL specific errors 43 | @{ 44 | @ingroup ssi_pal 45 | 46 | */ 47 | 48 | #ifdef __cplusplus 49 | extern "C" 50 | { 51 | #endif 52 | 53 | /*! PAL error base.*/ 54 | #define SASI_PAL_BASE_ERROR 0x0F000000 55 | 56 | /* Memory error returns */ 57 | /*! Buffer 1 is greater than buffer 2 error.*/ 58 | #define SASI_PAL_MEM_BUF1_GREATER SASI_PAL_BASE_ERROR + 0x01UL 59 | /*! Buffer 2 is greater than buffer 1 error.*/ 60 | #define SASI_PAL_MEM_BUF2_GREATER SASI_PAL_BASE_ERROR + 0x02UL 61 | 62 | /* Semaphore error returns */ 63 | /*! Semaphor creation failed.*/ 64 | #define SASI_PAL_SEM_CREATE_FAILED SASI_PAL_BASE_ERROR + 0x03UL 65 | /*! Semaphor deletion failed.*/ 66 | #define SASI_PAL_SEM_DELETE_FAILED SASI_PAL_BASE_ERROR + 0x04UL 67 | /*! Semaphor reached timeout.*/ 68 | #define SASI_PAL_SEM_WAIT_TIMEOUT SASI_PAL_BASE_ERROR + 0x05UL 69 | /*! Semaphor wait failed.*/ 70 | #define SASI_PAL_SEM_WAIT_FAILED SASI_PAL_BASE_ERROR + 0x06UL 71 | /*! Semaphor release failed.*/ 72 | #define SASI_PAL_SEM_RELEASE_FAILED SASI_PAL_BASE_ERROR + 0x07UL 73 | /*! PAL illegal address.*/ 74 | #define SASI_PAL_ILLEGAL_ADDRESS SASI_PAL_BASE_ERROR + 0x08UL 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | /** 80 | @} 81 | */ 82 | #endif 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_file_plat.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | 38 | #ifndef _SSI_PAL_FILE_INT_H 39 | #define _SSI_PAL_FILE_INT_H 40 | 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | #include "stdio.h" 48 | 49 | /** 50 | * @brief File Description: 51 | * This file contains wrapper functions for file related operations. 52 | */ 53 | 54 | /**** ----- Files General Definitions ----- ****/ 55 | 56 | /* Definitions for file modes */ 57 | #define SASI_PAL_MAX_SIZE_MODE 4 58 | #define SASI_PAL_NUM_OF_SUPPORT_MODES 12 59 | 60 | typedef char SaSiPalFileModeStr_t[SASI_PAL_MAX_SIZE_MODE]; 61 | 62 | typedef SaSiPalFileModeStr_t SaSiPalFileModesTable_t[SASI_PAL_NUM_OF_SUPPORT_MODES]; 63 | 64 | extern const SaSiPalFileModeStr_t SaSiPalFileModeTable[]; 65 | /**** ------------------------------------- ****/ 66 | 67 | //#define _SaSiFile_t FILE 68 | 69 | /*---------------------------- 70 | PUBLIC FUNCTIONS 71 | -----------------------------------*/ 72 | /** 73 | * @brief A wrapper for fopen functionality (to create a new file, the file is opened for read and 74 | * write). 75 | * 76 | */ 77 | #define _SaSi_PalFileCreate(aFileName) SaSi_PalFOpen(aFileName, SASI_PAL_WriteAndRead) 78 | 79 | /** 80 | * @brief A wrapper for fopen functionality. SaSiPalFileModeTable contains all possible modes 81 | * for fopen 82 | * 83 | */ 84 | #define _SaSi_PalFOpen(aFileName, aFileMode) ((SaSiFile_t)fopen(aFileName, SaSiPalFileModeTable[aFileMode])) 85 | 86 | /** 87 | * @brief A wrapper for fclose functionality. 88 | * 89 | */ 90 | #define _SaSi_PalFClose(aFileHandle) fclose((FILE*)aFileHandle) 91 | 92 | /** 93 | * @brief A wrapper for fseek functionality 94 | * 95 | */ 96 | #define _SaSi_PalFSeek(aFileHandle, aOffset, aSeekOrigin) fseek((FILE*)aFileHandle, aOffset, aSeekOrigin) 97 | 98 | /** 99 | * @brief A wrapper for ftell functionality 100 | * 101 | */ 102 | #define _SaSi_PalFTell(aFileHandle) ftell((FILE*)aFileHandle) 103 | 104 | /** 105 | * @brief A wrapper for fread functionality 106 | * 107 | */ 108 | #define _SaSi_PalFRead(aFileHandle, aBuffer, aSize) fread(aBuffer, 1, aSize, (FILE*)aFileHandle) 109 | 110 | /** 111 | * @brief A wrapper for fwrite functionality 112 | * 113 | */ 114 | #define _SaSi_PalFWrite(aFileHandle, aBuffer, aSize) fwrite(aBuffer, 1, aSize, (FILE*)aFileHandle) 115 | /** 116 | * @brief A wrapper for fflush functionality 117 | * 118 | */ 119 | #define _SaSi_PalFFlush(aFileHandle) fflush((FILE*)aFileHandle) 120 | 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | #endif 127 | 128 | 129 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_fips.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_PAL_FIPS_H 37 | #define _SSI_PAL_FIPS_H 38 | 39 | /*! 40 | @file 41 | @brief This file contains definitions that are used by the FIPS related APIs. The implementation of these functions 42 | need to be replaced according to Platform and OS. 43 | */ 44 | 45 | #include "ssi_pal_types_plat.h" 46 | #include "crys_fips.h" 47 | #include "crys_fips_defs.h" 48 | 49 | /** 50 | * @brief This function purpose is to get the FIPS state. 51 | * 52 | * 53 | * @return Zero on success. 54 | * @return A non-zero value on failure. 55 | */ 56 | SaSiError_t SaSi_PalFipsGetState(CC_FipsState_t *pFipsState); 57 | 58 | 59 | /** 60 | * @brief This function purpose is to get the FIPS Error. 61 | * 62 | * 63 | * @return Zero on success. 64 | * @return A non-zero value on failure. 65 | */ 66 | SaSiError_t SaSi_PalFipsGetError(CC_FipsError_t *pFipsError); 67 | 68 | 69 | /** 70 | * @brief This function purpose is to get the FIPS trace. 71 | * 72 | * 73 | * @return Zero on success. 74 | * @return A non-zero value on failure. 75 | */ 76 | SaSiError_t SaSi_PalFipsGetTrace(CC_FipsTrace_t *pFipsTrace); 77 | 78 | 79 | /** 80 | * @brief This function purpose is to set the FIPS state. 81 | * 82 | * 83 | * @return Zero on success. 84 | * @return A non-zero value on failure. 85 | */ 86 | SaSiError_t SaSi_PalFipsSetState(CC_FipsState_t fipsState); 87 | 88 | 89 | /** 90 | * @brief This function purpose is to set the FIPS error. 91 | * 92 | * 93 | * @return Zero on success. 94 | * @return A non-zero value on failure. 95 | */ 96 | SaSiError_t SaSi_PalFipsSetError(CC_FipsError_t fipsError); 97 | 98 | 99 | /** 100 | * @brief This function purpose is to set the FIPS trace. 101 | * 102 | * 103 | * @return Zero on success. 104 | * @return A non-zero value on failure. 105 | */ 106 | SaSiError_t SaSi_PalFipsSetTrace(CC_FipsTrace_t fipsTrace); 107 | 108 | 109 | /** 110 | * @brief This function should push the FIPS TEE library error towards the REE library, 111 | * the FIPS error can occur while running KAT tests at library init or while running 112 | * conditional or continues tests 113 | * 114 | * @return Zero on success. 115 | * @return A non-zero value on failure. 116 | */ 117 | SaSiError_t SaSi_PalFipsNotifyUponTeeError(void); 118 | 119 | #endif // _SSI_PAL_FIPS_H -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_init.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef _SSI_PAL_INIT_H 38 | #define _SSI_PAL_INIT_H 39 | 40 | #include "ssi_pal_types.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /*! 48 | @file 49 | @brief This file contains the PAL layer entry point, it includes the definitions and APIs for PAL initialization and termination. 50 | @defgroup ssi_pal_init CryptoCell PAL entry\exit point APIs 51 | @{ 52 | @ingroup ssi_pal 53 | 54 | */ 55 | 56 | /** 57 | * @brief This function Performs all initializations that may be required by the customer's PAL implementation, specifically by the DMA-able buffer 58 | * scheme. The existing implementation allocates a contiguous memory pool that is later used by the ARM TrustZone CryptoCell TEE implementation. 59 | * In case no initializations are needed in the customer's environment, the function can be minimized to return OK. 60 | * It is called by ::SaSi_LibInit. 61 | * 62 | * @return A non-zero value in case of failure. 63 | */ 64 | int SaSi_PalInit(void); 65 | 66 | 67 | 68 | /** 69 | * @brief This function is used to terminate the PAL implementation and free the resources that were taken by ::SaSi_PalInit. 70 | * 71 | * @return Void. 72 | */ 73 | void SaSi_PalTerminate(void); 74 | 75 | 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | /** 81 | @} 82 | */ 83 | #endif 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_list.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_PAL_LIST_H 37 | #define _SSI_PAL_LIST_H 38 | 39 | 40 | typedef struct SaSi_PalListItem { 41 | struct SaSi_PalListItem *prev; 42 | struct SaSi_PalListItem *next; 43 | } SaSi_PalListItem_s; 44 | 45 | /*! 46 | * Initializes a list. Prev/Next points to the same head object. 47 | * 48 | * \param head The head of the list. 49 | */ 50 | static inline void SaSi_PalListInit(SaSi_PalListItem_s *head) 51 | { 52 | head->prev = head; 53 | head->next = head; 54 | } 55 | 56 | /*! 57 | * Add a new list item after head of list. 58 | * 59 | * \param new New entry to be added 60 | * \param head List head to add it after 61 | */ 62 | static inline void SaSi_PalListAdd(SaSi_PalListItem_s *new, SaSi_PalListItem_s *head) 63 | { 64 | SaSi_PalListItem_s *next = head->next; 65 | 66 | next->prev = new; 67 | new->next = next; 68 | new->prev = head; 69 | head->next = new; 70 | } 71 | 72 | /*! 73 | * Add a new list item after head of list. 74 | * 75 | * \param new New entry to be added 76 | * \param head List head to add it after 77 | */ 78 | static inline void SaSi_PalListAddTail(SaSi_PalListItem_s *new, SaSi_PalListItem_s *head) 79 | { 80 | SaSi_PalListItem_s *prev = head->prev; 81 | 82 | prev->next = new; 83 | new->next = head; 84 | new->prev = prev; 85 | head->prev = new; 86 | } 87 | 88 | /*! 89 | * Deletes entry from list. 90 | * 91 | * \param item The item to delete from the list. 92 | */ 93 | static inline void SaSi_PalListDel(SaSi_PalListItem_s *item) 94 | { 95 | SaSi_PalListItem_s *prev = item->prev; 96 | SaSi_PalListItem_s *next = item->next; 97 | 98 | prev->next = next; 99 | next->prev = prev; 100 | 101 | item->next = item; 102 | item->prev = item; 103 | } 104 | 105 | /*! 106 | * Checks whether a list is empty. 107 | * 108 | * \param head The list's head 109 | * 110 | * \return int True if empty list, False otherwise. 111 | */ 112 | static inline int SaSi_PalIsListEmpty(const SaSi_PalListItem_s *head) 113 | { 114 | return (head->next == head); 115 | } 116 | 117 | #endif 118 | 119 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_memmap.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | 38 | #ifndef _SSI_PAL_MEMMAP_H 39 | #define _SSI_PAL_MEMMAP_H 40 | 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | 48 | #include "ssi_pal_types.h" 49 | /*! 50 | @file 51 | @brief This file contains functions for memory mapping 52 | None of the described functions will check the input parameters so the behavior 53 | of the APIs in illegal parameters case is dependent on the operating system behavior. 54 | @defgroup ssi_pal_memmap CryptoCell PAL memory mapping APIs 55 | @{ 56 | @ingroup ssi_pal 57 | 58 | */ 59 | 60 | 61 | /*---------------------------- 62 | PUBLIC FUNCTIONS 63 | -----------------------------------*/ 64 | 65 | /** 66 | * @brief This function purpose is to return the base virtual address that maps the 67 | * base physical address 68 | * 69 | * @return Zero on success. 70 | * @return A non-zero value in case of failure. 71 | */ 72 | uint32_t SaSi_PalMemMap(uint32_t physicalAddress, /*!< [in] Start physical address of the I/O range to be mapped. */ 73 | uint32_t mapSize, /*!< [in] Number of bytes that were mapped. */ 74 | uint32_t **ppVirtBuffAddr /*!< [out] Pointer to the base virtual address to which the physical pages were mapped. */ ); 75 | 76 | 77 | /** 78 | * @brief This function purpose is to Unmap a specified address range previously mapped 79 | * by SaSi_PalMemMap. 80 | * 81 | * @return Zero on success. 82 | * @return A non-zero value in case of failure. 83 | */ 84 | uint32_t SaSi_PalMemUnMap(uint32_t *pVirtBuffAddr, /*!< [in] Pointer to the base virtual address to which the physical pages were mapped. */ 85 | uint32_t mapSize /*!< [in] Number of bytes that were mapped. */); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | /** 91 | @} 92 | */ 93 | #endif 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_mutex.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef _SSI_PAL_MUTEX_H 38 | #define _SSI_PAL_MUTEX_H 39 | 40 | #include "ssi_pal_mutex_plat.h" 41 | #include "ssi_pal_types_plat.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" 45 | { 46 | #endif 47 | 48 | /*! 49 | @file 50 | @brief This file contains functions for resource management (mutex operations). 51 | The functions implementations are generally just wrappers to different operating system calls. 52 | None of the described functions will check the input parameters so the behavior 53 | of the APIs in illegal parameters case is dependent on the operating system behavior. 54 | @defgroup ssi_pal_mutex CryptoCell PAL mutex APIs 55 | @{ 56 | @ingroup ssi_pal 57 | */ 58 | 59 | 60 | 61 | 62 | /*---------------------------- 63 | PUBLIC FUNCTIONS 64 | -----------------------------------*/ 65 | 66 | /** 67 | * @brief This function purpose is to create a mutex. 68 | * 69 | * 70 | * @return Zero on success. 71 | * @return A non-zero value on failure. 72 | */ 73 | SaSiError_t SaSi_PalMutexCreate(SaSi_PalMutex *pMutexId /*!< [out] Pointer to created mutex handle. */); 74 | 75 | 76 | /** 77 | * @brief This function purpose is to destroy a mutex. 78 | * 79 | * 80 | * @return Zero on success. 81 | * @return A non-zero value on failure. 82 | */ 83 | SaSiError_t SaSi_PalMutexDestroy(SaSi_PalMutex *pMutexId /*!< [in] Pointer to mutex handle. */); 84 | 85 | 86 | /** 87 | * @brief This function purpose is to Wait for Mutex with aTimeOut. aTimeOut is 88 | * specified in milliseconds (SASI_INFINITE is blocking). 89 | * 90 | * @return Zero on success. 91 | * @return A non-zero value on failure. 92 | */ 93 | SaSiError_t SaSi_PalMutexLock (SaSi_PalMutex *pMutexId, /*!< [in] Pointer to Mutex handle. */ 94 | uint32_t aTimeOut /*!< [in] Timeout in mSec, or SASI_INFINITE. */); 95 | 96 | 97 | /** 98 | * @brief This function purpose is to release the mutex. 99 | * 100 | * @return Zero on success. 101 | * @return A non-zero value on failure. 102 | */ 103 | SaSiError_t SaSi_PalMutexUnlock (SaSi_PalMutex *pMutexId/*!< [in] Pointer to Mutex handle. */); 104 | 105 | 106 | 107 | 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | /** 113 | @} 114 | */ 115 | #endif 116 | 117 | 118 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_mutex_plat.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | 38 | #ifndef _SSI_PAL_MUTEX_PLAT_H 39 | #define _SSI_PAL_MUTEX_PLAT_H 40 | 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" 45 | { 46 | #endif 47 | /** 48 | * @brief File Description: 49 | * This file contains functions for resource management (semaphor operations). 50 | * The functions implementations are generally just wrappers to different operating system calls. 51 | * None of the described functions will check the input parameters so the behavior 52 | * of the APIs in illegal parameters case is dependent on the operating system behavior. 53 | * 54 | */ 55 | 56 | typedef uint32_t SaSi_PalMutex; 57 | 58 | 59 | 60 | /*---------------------------- 61 | PUBLIC FUNCTIONS 62 | -----------------------------------*/ 63 | 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_perf_plat.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_PAL_PERF_PLAT_H__ 37 | #define _SSI_PAL_PERF_PLAT_H__ 38 | 39 | 40 | 41 | 42 | typedef unsigned int SaSi_PalPerfData_t; 43 | 44 | /** 45 | * @brief DSM environment bug - sometimes very long write operation. 46 | * to overcome this bug we added while to make sure write opeartion is completed 47 | * 48 | * @param[in] 49 | * * 50 | * @return None 51 | */ 52 | void SaSi_PalDsmWorkarround(void); 53 | 54 | 55 | #endif /*_SSI_PAL_PERF_PLAT_H__*/ 56 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_sem_plat.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | 38 | #ifndef _SSI_PAL_SEM_INT__H 39 | #define _SSI_PAL_SEM_INT__H 40 | 41 | 42 | 43 | #ifdef __cplusplus 44 | extern "C" 45 | { 46 | #endif 47 | #include "ssi_pal_types.h" 48 | /** 49 | * @brief File Description: 50 | * This file contains functions for resource management (semaphor operations). 51 | * The functions implementations are generally just wrappers to different operating system calls. 52 | * None of the described functions will check the input parameters so the behavior 53 | * of the APIs in illegal parameters case is dependent on the operating system behavior. 54 | * 55 | */ 56 | 57 | typedef int DX_PAL_SEM; 58 | 59 | 60 | 61 | /*---------------------------- 62 | PUBLIC FUNCTIONS 63 | -----------------------------------*/ 64 | 65 | /** 66 | * @brief This function purpose is to create a semaphore. 67 | * 68 | * 69 | * @param[out] aSemId - Pointer to created semaphor handle 70 | * @param[in] aInitialVal - Initial semaphore value 71 | * 72 | * @return The return values is according to operating system return values. 73 | */ 74 | SaSiError_t _SaSi_PalSemCreate( DX_PAL_SEM *aSemId, uint32_t aInitialVal ); 75 | 76 | #define _SaSi_PalSemCreate(aSemId,aInitialVal) SASI_SUCCESS 77 | /** 78 | * @brief This function purpose is to delete a semaphore 79 | * 80 | * 81 | * @param[in] aSemId - Semaphore handle 82 | * 83 | * @return The return values is according to operating system return values. 84 | */ 85 | SaSiError_t _SaSi_PalSemDelete( DX_PAL_SEM *aSemId ); 86 | 87 | #define _SaSi_PalSemDelete( aSemId ) SASI_SUCCESS 88 | /** 89 | * @brief This function purpose is to Wait for semaphore with aTimeOut. aTimeOut is 90 | * specified in milliseconds. 91 | * 92 | * 93 | * @param[in] aSemId - Semaphore handle 94 | * @param[in] aTimeOut - timeout in mSec, or SASI_INFINITE 95 | * 96 | * @return The return values is according to operating system return values. 97 | */ 98 | SaSiError_t _SaSi_PalSemWait(DX_PAL_SEM aSemId, uint32_t aTimeOut); 99 | 100 | #define _SaSi_PalSemWait(aSemId, aTimeOut) SASI_SUCCESS 101 | /** 102 | * @brief This function purpose is to signal the semaphore. 103 | * 104 | * 105 | * @param[in] aSemId - Semaphore handle 106 | * 107 | * @return The return values is according to operating system return values. 108 | */ 109 | SaSiError_t _SaSi_PalSemGive(DX_PAL_SEM aSemId); 110 | 111 | #define _SaSi_PalSemGive(aSemId) SASI_SUCCESS 112 | 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | #endif 119 | 120 | 121 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_trng.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef _SSI_PAL_TRNG_H 38 | #define _SSI_PAL_TRNG_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /*---------------------------- 46 | PUBLIC FUNCTIONS 47 | -----------------------------------*/ 48 | 49 | /** 50 | * @brief This function purpose is to get TRNG characterization parameters. 51 | * 52 | * 53 | * @return Zero on success. 54 | * @return A non-zero value on failure. 55 | */ 56 | SaSiError_t SaSi_PalTrngParameterGet(uint32_t *SubSamplingRatio /*!< [out] TRNG characterization parameters, array size = 4. */); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | /** 62 | @} 63 | */ 64 | #endif 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pal_types_plat.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | /*! @file 37 | @brief This file contains basic type definitions that are platform dependent. 38 | */ 39 | #ifndef SSI_PAL_TYPES_PLAT_H 40 | #define SSI_PAL_TYPES_PLAT_H 41 | /* Host specific types for standard (ISO-C99) compilant platforms */ 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | typedef uintptr_t SaSiVirtAddr_t; 48 | typedef uint32_t SaSiBool_t; 49 | typedef uint32_t SaSiStatus; 50 | 51 | #define SaSiError_t SaSiStatus 52 | #define SASI_INFINITE 0xFFFFFFFF 53 | 54 | #define CEXPORT_C 55 | #define CIMPORT_C 56 | 57 | #endif /*SSI_PAL_TYPES_PLAT_H*/ 58 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_pka_hw_plat_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | 37 | #ifndef PKA_HW_PLAT_DEFS_H 38 | #define PKA_HW_PLAT_DEFS_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /*! 46 | @file 47 | @brief Contains the enums and definitions that are used in the PKA code (definitions that are platform dependent). 48 | @defgroup ssi_pka_hw_plat_defs CryptoCell PKA specific types and definitions 49 | @{ 50 | @ingroup cryptocell_pka 51 | 52 | */ 53 | 54 | /*! Size of PKA engine word.*/ 55 | #define SASI_PKA_WORD_SIZE_IN_BITS 64 56 | /*! Maximal supported modulus size in bits. */ 57 | #define CRYS_SRP_MAX_MODULUS_SIZE_IN_BITS 3072 58 | /*! Maximal supported modulus size in RSA in bits. */ 59 | #define CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 2048 60 | /*! Maximal supported key generation size in RSA in bits. */ 61 | #define CRYS_RSA_MAX_KEY_GENERATION_HW_SIZE_BITS 2048 62 | 63 | /*! PKA operations maximal count of extra bits. */ 64 | #define PKA_EXTRA_BITS 8 65 | /*! PKA operations number of memory registers. */ 66 | #define PKA_MAX_COUNT_OF_PHYS_MEM_REGS 32 67 | 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | /** 73 | @} 74 | */ 75 | #endif //PKA_HW_PLAT_DEFS_H 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_sram_map.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_SRAM_MAP_H_ 37 | #define _SSI_SRAM_MAP_H_ 38 | 39 | /*! 40 | @file 41 | @brief This file contains internal SRAM mapping definitions. 42 | @defgroup ssi_sram_map CryptoCell SRAM mapping APIs 43 | @{ 44 | @ingroup cryptocell_api 45 | 46 | */ 47 | 48 | #ifdef __cplusplus 49 | extern "C" 50 | { 51 | #endif 52 | 53 | /*! PKA base address in the PKA SRAM. */ 54 | #define SASI_SRAM_PKA_BASE_ADDRESS 0x0 55 | /*! PKA SRAM size in KB. */ 56 | #define SASI_PKA_SRAM_SIZE_IN_KBYTES 4 57 | 58 | /*! RND SRAM address. */ 59 | #define SASI_SRAM_RND_HW_DMA_ADDRESS 0x0 60 | /*! Addresses 0K-2KB in SRAM reserved for RND operations. */ 61 | #define SASI_SRAM_RND_MAX_SIZE 0x800 62 | /*! SRAM maximal size. */ 63 | #define SASI_SRAM_MAX_SIZE 0x1000 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | /** 69 | @} 70 | */ 71 | #endif /*_SSI_SRAM_MAP_H_*/ 72 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_util_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_UTIL_DEFS_H 37 | #define _SSI_UTIL_DEFS_H 38 | 39 | /*! 40 | @defgroup ssi_utils CryptoCell utility APIs 41 | @{ 42 | @ingroup cryptocell_api 43 | @brief This group is the utility apis group 44 | @} 45 | 46 | @file 47 | @brief This file contains CryptoCell Util general definitions. 48 | @defgroup ssi_utils_defs CryptoCell utils general definitions 49 | @{ 50 | @ingroup ssi_utils 51 | 52 | */ 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" 57 | { 58 | #endif 59 | 60 | #include "ssi_pal_types_plat.h" 61 | #include "ssi_util_key_derivation_defs.h" 62 | 63 | 64 | /****************************************************************************** 65 | * DEFINITIONS 66 | ******************************************************************************/ 67 | /*! Supported AES key size in bits. */ 68 | #define SASI_UTIL_AES_128BIT_SIZE 16 // same as SEP_AES_128_BIT_KEY_SIZE 69 | /*****************************************/ 70 | /* CMAC derive key definitions*/ 71 | /*****************************************/ 72 | /*! Minimal data size for CMAC derivation operation. */ 73 | #define SASI_UTIL_CMAC_DERV_MIN_DATA_IN_SIZE SASI_UTIL_FIX_DATA_MIN_SIZE_IN_BYTES+2 74 | /*! Maximal data size for CMAC derivation operation. */ 75 | #define SASI_UTIL_CMAC_DERV_MAX_DATA_IN_SIZE SASI_UTIL_MAX_KDF_SIZE_IN_BYTES 76 | /*! AES CMAC result size in bytes. */ 77 | #define SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES 0x10UL 78 | /*! AES CMAC result size in words. */ 79 | #define SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_WORDS (SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES/4) 80 | 81 | /*! Util Error type. */ 82 | typedef uint32_t SaSiUtilError_t; 83 | /*! Defines the CMAC result buffer. */ 84 | typedef uint8_t SaSiUtilAesCmacResult_t[SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES]; 85 | 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | /** 91 | @} 92 | */ 93 | #endif /*_SSI_UTIL_DEFS_H*/ 94 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_util_error.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_UTIL_ERROR_H 37 | #define _SSI_UTIL_ERROR_H 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /*! 45 | @file 46 | @brief This module contains the definitions of the UTIL module errors. 47 | @defgroup ssi_utils_errors CryptoCell utils error definitions 48 | @{ 49 | @ingroup ssi_utils 50 | 51 | */ 52 | 53 | /***********************/ 54 | /* Util return codes */ 55 | /***********************/ 56 | 57 | /*! Success definition. */ 58 | #define SASI_UTIL_OK 0x00UL 59 | /*! Error base number definition. */ 60 | #define SASI_UTIL_MODULE_ERROR_BASE 0x80000000 61 | 62 | /*! Illegal key type. */ 63 | #define SASI_UTIL_INVALID_KEY_TYPE (SASI_UTIL_MODULE_ERROR_BASE + 0x00UL) 64 | /*! Illegal data in pointer. */ 65 | #define SASI_UTIL_DATA_IN_POINTER_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x01UL) 66 | /*! Illegal data in size. */ 67 | #define SASI_UTIL_DATA_IN_SIZE_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x02UL) 68 | /*! Illegal data out pointer. */ 69 | #define SASI_UTIL_DATA_OUT_POINTER_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x03UL) 70 | /*! Illegal data out size. */ 71 | #define SASI_UTIL_DATA_OUT_SIZE_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x04UL) 72 | /*! Fatal error. */ 73 | #define SASI_UTIL_FATAL_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x05UL) 74 | /*! Illegal parameters. */ 75 | #define SASI_UTIL_ILLEGAL_PARAMS_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x06UL) 76 | /*! Invalid address given. */ 77 | #define SASI_UTIL_BAD_ADDR_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x07UL) 78 | /*! Illegal domain for endorsement key. */ 79 | #define SASI_UTIL_EK_DOMAIN_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x08UL) 80 | /*! Kdr is not valid. */ 81 | #define SASI_UTIL_KDR_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x09UL) 82 | /*! LCS is not valid. */ 83 | #define SASI_UTIL_LCS_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x0AUL) 84 | /*! session key is not valid. */ 85 | #define SASI_UTIL_SESSION_KEY_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x0BUL) 86 | /*! Illegal user key size. */ 87 | #define SASI_UTIL_INVALID_USER_KEY_SIZE (SASI_UTIL_MODULE_ERROR_BASE + 0x0DUL) 88 | /*! Illegal LCS for the required operation. */ 89 | #define SASI_UTIL_ILLEGAL_LCS_FOR_OPERATION_ERR (SASI_UTIL_MODULE_ERROR_BASE + 0x0EUL) 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | /** 95 | @} 96 | */ 97 | #endif /*_SSI_UTIL_ERROR_H*/ 98 | -------------------------------------------------------------------------------- /src/nrf_cc310/include/ssi_util_key_derivation_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef _SSI_UTIL_KEY_DERIVATION_DEFS_H 37 | #define _SSI_UTIL_KEY_DERIVATION_DEFS_H 38 | 39 | /*! 40 | @file 41 | @brief This file contains the definitions for the key derivation API. 42 | @defgroup ssi_utils_key_defs CryptoCell utils general key definitions 43 | @{ 44 | @ingroup ssi_utils 45 | 46 | */ 47 | 48 | #ifdef __cplusplus 49 | extern "C" 50 | { 51 | #endif 52 | 53 | /****************************************************************************** 54 | * DEFINITIONS 55 | ******************************************************************************/ 56 | 57 | /*! Maximal label length in bytes. */ 58 | #define SASI_UTIL_MAX_LABEL_LENGTH_IN_BYTES 64 59 | /*! Maximal context length in bytes. */ 60 | #define SASI_UTIL_MAX_CONTEXT_LENGTH_IN_BYTES 64 61 | 62 | /*! Minimal fixed data size in bytes. */ 63 | #define SASI_UTIL_FIX_DATA_MIN_SIZE_IN_BYTES 3 /*!< \internal counter, 0x00, lengt(-0xff) */ 64 | /*! Maximal fixed data size in bytes. */ 65 | #define SASI_UTIL_FIX_DATA_MAX_SIZE_IN_BYTES 4 /*!< \internal counter, 0x00, lengt(0x100-0xff0) */ 66 | 67 | /*! Maximal derived key material size in bytes. */ 68 | #define SASI_UTIL_MAX_KDF_SIZE_IN_BYTES (SASI_UTIL_MAX_LABEL_LENGTH_IN_BYTES+ \ 69 | SASI_UTIL_MAX_CONTEXT_LENGTH_IN_BYTES+SASI_UTIL_FIX_DATA_MAX_SIZE_IN_BYTES) 70 | 71 | /*! Maximal derived key size in bytes. */ 72 | #define SASI_UTIL_MAX_DERIVED_KEY_SIZE_IN_BYTES 4080 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | /** 78 | @} 79 | */ 80 | #endif /*_SSI_UTIL_KEY_DERIVATION_DEFS_H*/ 81 | 82 | -------------------------------------------------------------------------------- /src/nrf_cc310/license.txt: -------------------------------------------------------------------------------- 1 | ARM Object Code and Header Files License 2 | Version 1.0 3 | 4 | Redistribution. 5 | 6 | Redistribution and use of object code, header files, and 7 | documentation, without modification, are permitted provided that the following 8 | conditions are met: 9 | 1) Redistributions must reproduce the above copyright notice and the 10 | following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 2) Unless to the extent explicitly permitted by law, no reverse 13 | engineering, decompilation, or disassembly of is permitted. 14 | 3) Redistribution and use is permitted solely for the purpose of 15 | developing or executing applications that are targeted for use 16 | on an ARM-based product. 17 | 18 | DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 20 | NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, 21 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------