Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file pkcs11.c |
| 3 | * |
| 4 | * \brief Wrapper for PKCS#11 library libpkcs11-helper |
| 5 | * |
| 6 | * \author Adriaan de Jong <dejong@fox-it.com> |
| 7 | * |
Manuel Pégourié-Gonnard | 6fb8187 | 2015-07-27 11:11:48 +0200 | [diff] [blame] | 8 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame^] | 9 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 10 | * |
| 11 | * This file is provided under the Apache License 2.0, or the |
| 12 | * GNU General Public License v2.0 or later. |
| 13 | * |
| 14 | * ********** |
| 15 | * Apache License 2.0: |
Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 16 | * |
| 17 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 18 | * not use this file except in compliance with the License. |
| 19 | * You may obtain a copy of the License at |
| 20 | * |
| 21 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 22 | * |
| 23 | * Unless required by applicable law or agreed to in writing, software |
| 24 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 25 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 26 | * See the License for the specific language governing permissions and |
| 27 | * limitations under the License. |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 28 | * |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame^] | 29 | * ********** |
| 30 | * |
| 31 | * ********** |
| 32 | * GNU General Public License v2.0 or later: |
| 33 | * |
| 34 | * This program is free software; you can redistribute it and/or modify |
| 35 | * it under the terms of the GNU General Public License as published by |
| 36 | * the Free Software Foundation; either version 2 of the License, or |
| 37 | * (at your option) any later version. |
| 38 | * |
| 39 | * This program is distributed in the hope that it will be useful, |
| 40 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 41 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 42 | * GNU General Public License for more details. |
| 43 | * |
| 44 | * You should have received a copy of the GNU General Public License along |
| 45 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 46 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 47 | * |
| 48 | * ********** |
| 49 | * |
Manuel Pégourié-Gonnard | fe44643 | 2015-03-06 13:17:10 +0000 | [diff] [blame] | 50 | * This file is part of mbed TLS (https://tls.mbed.org) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 51 | */ |
| 52 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 53 | #include "mbedtls/pkcs11.h" |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 54 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 55 | #if defined(MBEDTLS_PKCS11_C) |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 56 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 57 | #include "mbedtls/md.h" |
| 58 | #include "mbedtls/oid.h" |
| 59 | #include "mbedtls/x509_crt.h" |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 60 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 61 | #if defined(MBEDTLS_PLATFORM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 62 | #include "mbedtls/platform.h" |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 63 | #else |
Paul Bakker | 7dc4c44 | 2014-02-01 22:50:26 +0100 | [diff] [blame] | 64 | #include <stdlib.h> |
Manuel Pégourié-Gonnard | 7551cb9 | 2015-05-26 16:04:06 +0200 | [diff] [blame] | 65 | #define mbedtls_calloc calloc |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 66 | #define mbedtls_free free |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 67 | #endif |
| 68 | |
Manuel Pégourié-Gonnard | 3a89559 | 2015-05-27 17:09:21 +0200 | [diff] [blame] | 69 | #include <string.h> |
| 70 | |
Manuel Pégourié-Gonnard | eab147c | 2015-04-29 01:10:10 +0200 | [diff] [blame] | 71 | void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx ) |
| 72 | { |
| 73 | memset( ctx, 0, sizeof( mbedtls_pkcs11_context ) ); |
| 74 | } |
| 75 | |
| 76 | int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11_cert ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 77 | { |
| 78 | int ret = 1; |
| 79 | unsigned char *cert_blob = NULL; |
| 80 | size_t cert_blob_size = 0; |
| 81 | |
| 82 | if( cert == NULL ) |
| 83 | { |
| 84 | ret = 2; |
| 85 | goto cleanup; |
| 86 | } |
| 87 | |
Paul Bakker | b9e4e2c | 2014-05-01 14:18:25 +0200 | [diff] [blame] | 88 | if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, NULL, |
| 89 | &cert_blob_size ) != CKR_OK ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 90 | { |
| 91 | ret = 3; |
| 92 | goto cleanup; |
| 93 | } |
| 94 | |
Manuel Pégourié-Gonnard | 7551cb9 | 2015-05-26 16:04:06 +0200 | [diff] [blame] | 95 | cert_blob = mbedtls_calloc( 1, cert_blob_size ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 96 | if( NULL == cert_blob ) |
| 97 | { |
| 98 | ret = 4; |
| 99 | goto cleanup; |
| 100 | } |
| 101 | |
Paul Bakker | b9e4e2c | 2014-05-01 14:18:25 +0200 | [diff] [blame] | 102 | if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, cert_blob, |
| 103 | &cert_blob_size ) != CKR_OK ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 104 | { |
| 105 | ret = 5; |
| 106 | goto cleanup; |
| 107 | } |
| 108 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 109 | if( 0 != mbedtls_x509_crt_parse( cert, cert_blob, cert_blob_size ) ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 110 | { |
| 111 | ret = 6; |
| 112 | goto cleanup; |
| 113 | } |
| 114 | |
| 115 | ret = 0; |
| 116 | |
| 117 | cleanup: |
| 118 | if( NULL != cert_blob ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 119 | mbedtls_free( cert_blob ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 120 | |
Paul Bakker | d8bb826 | 2014-06-17 14:06:49 +0200 | [diff] [blame] | 121 | return( ret ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | |
Manuel Pégourié-Gonnard | eab147c | 2015-04-29 01:10:10 +0200 | [diff] [blame] | 125 | int mbedtls_pkcs11_priv_key_bind( mbedtls_pkcs11_context *priv_key, |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 126 | pkcs11h_certificate_t pkcs11_cert ) |
| 127 | { |
| 128 | int ret = 1; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 129 | mbedtls_x509_crt cert; |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 130 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 131 | mbedtls_x509_crt_init( &cert ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 132 | |
| 133 | if( priv_key == NULL ) |
| 134 | goto cleanup; |
| 135 | |
Manuel Pégourié-Gonnard | 3a89559 | 2015-05-27 17:09:21 +0200 | [diff] [blame] | 136 | if( 0 != mbedtls_pkcs11_x509_cert_bind( &cert, pkcs11_cert ) ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 137 | goto cleanup; |
| 138 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 139 | priv_key->len = mbedtls_pk_get_len( &cert.pk ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 140 | priv_key->pkcs11h_cert = pkcs11_cert; |
| 141 | |
| 142 | ret = 0; |
| 143 | |
| 144 | cleanup: |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 145 | mbedtls_x509_crt_free( &cert ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 146 | |
Paul Bakker | d8bb826 | 2014-06-17 14:06:49 +0200 | [diff] [blame] | 147 | return( ret ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 148 | } |
| 149 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 150 | void mbedtls_pkcs11_priv_key_free( mbedtls_pkcs11_context *priv_key ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 151 | { |
| 152 | if( NULL != priv_key ) |
| 153 | pkcs11h_certificate_freeCertificate( priv_key->pkcs11h_cert ); |
| 154 | } |
| 155 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 156 | int mbedtls_pkcs11_decrypt( mbedtls_pkcs11_context *ctx, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 157 | int mode, size_t *olen, |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 158 | const unsigned char *input, |
| 159 | unsigned char *output, |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 160 | size_t output_max_len ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 161 | { |
| 162 | size_t input_len, output_len; |
| 163 | |
| 164 | if( NULL == ctx ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 165 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 166 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 167 | if( MBEDTLS_RSA_PRIVATE != mode ) |
| 168 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 169 | |
| 170 | output_len = input_len = ctx->len; |
| 171 | |
| 172 | if( input_len < 16 || input_len > output_max_len ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 173 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 174 | |
| 175 | /* Determine size of output buffer */ |
| 176 | if( pkcs11h_certificate_decryptAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, input, |
| 177 | input_len, NULL, &output_len ) != CKR_OK ) |
| 178 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 179 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | if( output_len > output_max_len ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 183 | return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 184 | |
| 185 | if( pkcs11h_certificate_decryptAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, input, |
| 186 | input_len, output, &output_len ) != CKR_OK ) |
| 187 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 188 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 189 | } |
| 190 | *olen = output_len; |
| 191 | return( 0 ); |
| 192 | } |
| 193 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 194 | int mbedtls_pkcs11_sign( mbedtls_pkcs11_context *ctx, |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 195 | int mode, |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 196 | mbedtls_md_type_t md_alg, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 197 | unsigned int hashlen, |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 198 | const unsigned char *hash, |
| 199 | unsigned char *sig ) |
| 200 | { |
Paul Bakker | db1f059 | 2014-03-26 14:53:47 +0100 | [diff] [blame] | 201 | size_t sig_len = 0, asn_len = 0, oid_size = 0; |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 202 | unsigned char *p = sig; |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 203 | const char *oid; |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 204 | |
| 205 | if( NULL == ctx ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 206 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 207 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 208 | if( MBEDTLS_RSA_PRIVATE != mode ) |
| 209 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 210 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 211 | if( md_alg != MBEDTLS_MD_NONE ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 212 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 213 | const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg ); |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 214 | if( md_info == NULL ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 215 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 216 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 217 | if( mbedtls_oid_get_oid_by_md( md_alg, &oid, &oid_size ) != 0 ) |
| 218 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 219 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 220 | hashlen = mbedtls_md_get_size( md_info ); |
Paul Bakker | db1f059 | 2014-03-26 14:53:47 +0100 | [diff] [blame] | 221 | asn_len = 10 + oid_size; |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Paul Bakker | db1f059 | 2014-03-26 14:53:47 +0100 | [diff] [blame] | 224 | sig_len = ctx->len; |
Paul Bakker | 66d5d07 | 2014-06-17 16:39:18 +0200 | [diff] [blame] | 225 | if( hashlen > sig_len || asn_len > sig_len || |
| 226 | hashlen + asn_len > sig_len ) |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 227 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 228 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 229 | } |
Paul Bakker | db1f059 | 2014-03-26 14:53:47 +0100 | [diff] [blame] | 230 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 231 | if( md_alg != MBEDTLS_MD_NONE ) |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 232 | { |
| 233 | /* |
| 234 | * DigestInfo ::= SEQUENCE { |
| 235 | * digestAlgorithm DigestAlgorithmIdentifier, |
| 236 | * digest Digest } |
| 237 | * |
| 238 | * DigestAlgorithmIdentifier ::= AlgorithmIdentifier |
| 239 | * |
| 240 | * Digest ::= OCTET STRING |
| 241 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 242 | *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED; |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 243 | *p++ = (unsigned char) ( 0x08 + oid_size + hashlen ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 244 | *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED; |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 245 | *p++ = (unsigned char) ( 0x04 + oid_size ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 246 | *p++ = MBEDTLS_ASN1_OID; |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 247 | *p++ = oid_size & 0xFF; |
| 248 | memcpy( p, oid, oid_size ); |
| 249 | p += oid_size; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 250 | *p++ = MBEDTLS_ASN1_NULL; |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 251 | *p++ = 0x00; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 252 | *p++ = MBEDTLS_ASN1_OCTET_STRING; |
Steffan Karger | 28d81a0 | 2013-11-13 16:57:58 +0100 | [diff] [blame] | 253 | *p++ = hashlen; |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Paul Bakker | db1f059 | 2014-03-26 14:53:47 +0100 | [diff] [blame] | 256 | memcpy( p, hash, hashlen ); |
| 257 | |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 258 | if( pkcs11h_certificate_signAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, sig, |
Paul Bakker | db1f059 | 2014-03-26 14:53:47 +0100 | [diff] [blame] | 259 | asn_len + hashlen, sig, &sig_len ) != CKR_OK ) |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 260 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 261 | return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | return( 0 ); |
| 265 | } |
| 266 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 267 | #endif /* defined(MBEDTLS_PKCS11_C) */ |