|
| 1 | +/* cryif.c |
| 2 | + * |
| 3 | + * Copyright (C) 2006-2024 wolfSSL Inc. |
| 4 | + * |
| 5 | + * This file is part of wolfSSL. |
| 6 | + * |
| 7 | + * wolfSSL is free software; you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation; either version 2 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * wolfSSL is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program; if not, write to the Free Software |
| 19 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
| 20 | + */ |
| 21 | + |
| 22 | +/* AutoSAR 4.4 */ |
| 23 | +/* shim layer for use of wolfSSL crypto driver */ |
| 24 | + |
| 25 | + |
| 26 | +#ifdef HAVE_CONFIG_H |
| 27 | + #include <config.h> |
| 28 | +#endif |
| 29 | + |
| 30 | +#include <wolfssl/wolfcrypt/settings.h> |
| 31 | +#include <wolfssl/version.h> |
| 32 | +#include <wolfssl/wolfcrypt/port/autosar/Csm.h> |
| 33 | +#include <wolfssl/wolfcrypt/port/autosar/CryIf.h> |
| 34 | +#include <wolfssl/wolfcrypt/port/autosar/Crypto.h> |
| 35 | + |
| 36 | +#ifdef WOLFSSL_AUTOSAR |
| 37 | +#ifndef NO_WOLFSSL_AUTOSAR_CRYIF |
| 38 | + |
| 39 | +#include <wolfssl/wolfcrypt/logging.h> |
| 40 | + |
| 41 | +/* initialization function */ |
| 42 | +void CryIf_Init(const CryIf_ConfigType* in) |
| 43 | +{ |
| 44 | + (void)in; |
| 45 | + Crypto_Init(NULL); |
| 46 | +} |
| 47 | + |
| 48 | + |
| 49 | +void CryIf_GetVersionInfo(Std_VersionInfoType* ver) |
| 50 | +{ |
| 51 | + if (ver != NULL) { |
| 52 | + ver->vendorID = 0; /* no vendor or module ID */ |
| 53 | + ver->moduleID = 0; |
| 54 | + ver->sw_major_version = (LIBWOLFSSL_VERSION_HEX >> 24) & 0xFFF; |
| 55 | + ver->sw_minor_version = (LIBWOLFSSL_VERSION_HEX >> 12) & 0xFFF; |
| 56 | + ver->sw_patch_version = (LIBWOLFSSL_VERSION_HEX) & 0xFFF; |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | + |
| 61 | +/* returns E_OK on success */ |
| 62 | +Std_ReturnType CryIf_ProcessJob(uint32 id, Crypto_JobType* job) |
| 63 | +{ |
| 64 | + WOLFSSL_ENTER("CryIf_ProcessJob"); |
| 65 | + if (job == NULL) { |
| 66 | + return E_NOT_OK; |
| 67 | + } |
| 68 | + |
| 69 | + /* only handle synchronous jobs */ |
| 70 | + if (job->jobPrimitiveInfo->processingType != CRYPTO_PROCESSING_SYNC) { |
| 71 | + WOLFSSL_MSG("Crypto Interface only supporting synchronous jobs"); |
| 72 | + return E_NOT_OK; |
| 73 | + } |
| 74 | + |
| 75 | + return Crypto_ProcessJob(id, job); |
| 76 | +} |
| 77 | + |
| 78 | + |
| 79 | +/* not implemented yet since async not supported */ |
| 80 | +Std_ReturnType CryIf_CancelJob(uint32 id, Crypto_JobType* job) |
| 81 | +{ |
| 82 | + (void)id; |
| 83 | + (void)job; |
| 84 | + WOLFSSL_STUB("CryIf_CancelJob"); |
| 85 | + |
| 86 | + return E_NOT_OK; |
| 87 | +} |
| 88 | + |
| 89 | + |
| 90 | +/* return E_OK on success */ |
| 91 | +Std_ReturnType CryIf_KeyElementSet(uint32 keyId, uint32 eId, const uint8* key, |
| 92 | + uint32 keySz) |
| 93 | +{ |
| 94 | + if (key == NULL || keySz == 0) { |
| 95 | + /* report CRYIF_E_PARAM_POINTER to the DET */ |
| 96 | + return E_NOT_OK; |
| 97 | + } |
| 98 | + |
| 99 | + return Crypto_KeyElementSet(keyId, eId, key, keySz); |
| 100 | +} |
| 101 | +#endif /* NO_WOLFSSL_AUTOSAR_CRYIF */ |
| 102 | +#endif /* WOLFSSL_AUTOSAR */ |
| 103 | + |
0 commit comments