| bn_mul.h | | bn_mul.h | |
| | | | |
| skipping to change at line 554 | | skipping to change at line 554 | |
| asm( "st.a %0, %%a2 " : "=m" (s) :: \ | | asm( "st.a %0, %%a2 " : "=m" (s) :: \ | |
| "d0", "d1", "e2", "d4", "a2", "a3" ); | | "d0", "d1", "e2", "d4", "a2", "a3" ); | |
| | | | |
| #endif /* TriCore */ | | #endif /* TriCore */ | |
| | | | |
| #if defined(__arm__) | | #if defined(__arm__) | |
| | | | |
| #if defined(__thumb__) | | #if defined(__thumb__) | |
| | | | |
| #define MULADDC_INIT \ | | #define MULADDC_INIT \ | |
|
| asm( "ldr r0, %0 " :: "m" (s)); \ | | asm( \ | |
| asm( "ldr r1, %0 " :: "m" (d)); \ | | " \ | |
| asm( "ldr r2, %0 " :: "m" (c)); \ | | ldr r0, %3; \ | |
| asm( "ldr r3, %0 " :: "m" (b)); \ | | ldr r1, %4; \ | |
| asm( "lsr r7, r3, #16 " ); \ | | ldr r2, %5; \ | |
| asm( "mov r9, r7 " ); \ | | ldr r3, %6; \ | |
| asm( "lsl r7, r3, #16 " ); \ | | lsr r7, r3, #16; \ | |
| asm( "lsr r7, r7, #16 " ); \ | | mov r9, r7; \ | |
| asm( "mov r8, r7 " ); | | lsl r7, r3, #16; \ | |
| | | lsr r7, r7, #16; \ | |
| | | mov r8, r7; \ | |
| | | " | |
| | | | |
| #define MULADDC_CORE \ | | #define MULADDC_CORE \ | |
|
| asm( "ldmia r0!, {r6} " ); \ | | " \ | |
| asm( "lsr r7, r6, #16 " ); \ | | ldmia r0!, {r6}; \ | |
| asm( "lsl r6, r6, #16 " ); \ | | lsr r7, r6, #16; \ | |
| asm( "lsr r6, r6, #16 " ); \ | | lsl r6, r6, #16; \ | |
| asm( "mov r4, r8 " ); \ | | lsr r6, r6, #16; \ | |
| asm( "mul r4, r6 " ); \ | | mov r4, r8; \ | |
| asm( "mov r3, r9 " ); \ | | mul r4, r6; \ | |
| asm( "mul r6, r3 " ); \ | | mov r3, r9; \ | |
| asm( "mov r5, r9 " ); \ | | mul r6, r3; \ | |
| asm( "mul r5, r7 " ); \ | | mov r5, r9; \ | |
| asm( "mov r3, r8 " ); \ | | mul r5, r7; \ | |
| asm( "mul r7, r3 " ); \ | | mov r3, r8; \ | |
| asm( "lsr r3, r6, #16 " ); \ | | mul r7, r3; \ | |
| asm( "add r5, r5, r3 " ); \ | | lsr r3, r6, #16; \ | |
| asm( "lsr r3, r7, #16 " ); \ | | add r5, r5, r3; \ | |
| asm( "add r5, r5, r3 " ); \ | | lsr r3, r7, #16; \ | |
| asm( "add r4, r4, r2 " ); \ | | add r5, r5, r3; \ | |
| asm( "mov r2, #0 " ); \ | | add r4, r4, r2; \ | |
| asm( "adc r5, r2 " ); \ | | mov r2, #0; \ | |
| asm( "lsl r3, r6, #16 " ); \ | | adc r5, r2; \ | |
| asm( "add r4, r4, r3 " ); \ | | lsl r3, r6, #16; \ | |
| asm( "adc r5, r2 " ); \ | | add r4, r4, r3; \ | |
| asm( "lsl r3, r7, #16 " ); \ | | adc r5, r2; \ | |
| asm( "add r4, r4, r3 " ); \ | | lsl r3, r7, #16; \ | |
| asm( "adc r5, r2 " ); \ | | add r4, r4, r3; \ | |
| asm( "ldr r3, [r1] " ); \ | | adc r5, r2; \ | |
| asm( "add r4, r4, r3 " ); \ | | ldr r3, [r1]; \ | |
| asm( "adc r2, r5 " ); \ | | add r4, r4, r3; \ | |
| asm( "stmia r1!, {r4} " ); | | adc r2, r5; \ | |
| | | stmia r1!, {r4}; \ | |
| | | " | |
| | | | |
| #define MULADDC_STOP \ | | #define MULADDC_STOP \ | |
|
| asm( "str r2, %0 " : "=m" (c)); \ | | " \ | |
| asm( "str r1, %0 " : "=m" (d)); \ | | str r2, %0; \ | |
| asm( "str r0, %0 " : "=m" (s) :: \ | | str r1, %1; \ | |
| "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9" ); | | str r0, %2; \ | |
| | | " \ | |
| | | : "=m" (c), "=m" (d), "=m" (s) \ | |
| | | : "m" (s), "m" (d), "m" (c), "m" (b) \ | |
| | | : "r0", "r1", "r2", "r3", "r4", "r5", \ | |
| | | "r6", "r7", "r8", "r9" \ | |
| | | ); | |
| | | | |
| #else | | #else | |
| | | | |
| #define MULADDC_INIT \ | | #define MULADDC_INIT \ | |
|
| asm( "ldr r0, %0 " :: "m" (s)); \ | | asm( \ | |
| asm( "ldr r1, %0 " :: "m" (d)); \ | | " \ | |
| asm( "ldr r2, %0 " :: "m" (c)); \ | | ldr r0, %3; \ | |
| asm( "ldr r3, %0 " :: "m" (b)); | | ldr r1, %4; \ | |
| | | ldr r2, %5; \ | |
| | | ldr r3, %6; \ | |
| | | " | |
| | | | |
| #define MULADDC_CORE \ | | #define MULADDC_CORE \ | |
|
| asm( "ldr r4, [r0], #4 " ); \ | | " \ | |
| asm( "mov r5, #0 " ); \ | | ldr r4, [r0], #4; \ | |
| asm( "ldr r6, [r1] " ); \ | | mov r5, #0; \ | |
| asm( "umlal r2, r5, r3, r4 " ); \ | | ldr r6, [r1]; \ | |
| asm( "adds r7, r6, r2 " ); \ | | umlal r2, r5, r3, r4; \ | |
| asm( "adc r2, r5, #0 " ); \ | | adds r7, r6, r2; \ | |
| asm( "str r7, [r1], #4 " ); | | adc r2, r5, #0; \ | |
| | | str r7, [r1], #4; \ | |
| | | " | |
| | | | |
| #define MULADDC_STOP \ | | #define MULADDC_STOP \ | |
|
| asm( "str r2, %0 " : "=m" (c)); \ | | " \ | |
| asm( "str r1, %0 " : "=m" (d)); \ | | str r2, %0; \ | |
| asm( "str r0, %0 " : "=m" (s) :: \ | | str r1, %1; \ | |
| "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7" ); | | str r0, %2; \ | |
| | | " \ | |
| | | : "=m" (c), "=m" (d), "=m" (s) \ | |
| | | : "m" (s), "m" (d), "m" (c), "m" (b) \ | |
| | | : "r0", "r1", "r2", "r3", "r4", "r5", \ | |
| | | "r6", "r7" \ | |
| | | ); | |
| | | | |
| #endif /* Thumb */ | | #endif /* Thumb */ | |
| | | | |
| #endif /* ARMv3 */ | | #endif /* ARMv3 */ | |
| | | | |
| #if defined(__alpha__) | | #if defined(__alpha__) | |
| | | | |
| #define MULADDC_INIT \ | | #define MULADDC_INIT \ | |
| asm( "ldq $1, %0 " :: "m" (s)); \ | | asm( "ldq $1, %0 " :: "m" (s)); \ | |
| asm( "ldq $2, %0 " :: "m" (d)); \ | | asm( "ldq $2, %0 " :: "m" (d)); \ | |
| | | | |
End of changes. 6 change blocks. |
| 57 lines changed or deleted | | 79 lines changed or added | |
|
| config.h | | config.h | |
| | | | |
| skipping to change at line 282 | | skipping to change at line 282 | |
| * \def POLARSSL_SSL_HW_RECORD_ACCEL | | * \def POLARSSL_SSL_HW_RECORD_ACCEL | |
| * | | * | |
| * Enable hooking functions in SSL module for hardware acceleration of | | * Enable hooking functions in SSL module for hardware acceleration of | |
| * individual records. | | * individual records. | |
| * | | * | |
| * Uncomment this macro to enable hooking functions. | | * Uncomment this macro to enable hooking functions. | |
| #define POLARSSL_SSL_HW_RECORD_ACCEL | | #define POLARSSL_SSL_HW_RECORD_ACCEL | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| | | * \def POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO | |
| | | * | |
| | | * Enable support for receiving and parsing SSLv2 Client Hello messages for | |
| | | the | |
| | | * SSL Server module (POLARSSL_SSL_SRV_C) | |
| | | * | |
| | | * Comment this macro to disable support for SSLv2 Client Hello messages. | |
| | | */ | |
| | | #define POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO | |
| | | | |
| | | /** | |
| * \def POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | | * \def POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | |
| * | | * | |
| * If set, the X509 parser will not break-off when parsing an X509 certific
ate | | * If set, the X509 parser will not break-off when parsing an X509 certific
ate | |
| * and encountering an unknown critical extension. | | * and encountering an unknown critical extension. | |
| * | | * | |
| * Uncomment to prevent an error. | | * Uncomment to prevent an error. | |
| * | | * | |
| #define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | | #define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | |
| */ | | */ | |
| | | | |
| | | | |
| skipping to change at line 338 | | skipping to change at line 348 | |
| * TLS_RSA_WITH_AES_128_CBC_SHA | | * TLS_RSA_WITH_AES_128_CBC_SHA | |
| * TLS_RSA_WITH_AES_256_CBC_SHA | | * TLS_RSA_WITH_AES_256_CBC_SHA | |
| * TLS_DHE_RSA_WITH_AES_128_CBC_SHA | | * TLS_DHE_RSA_WITH_AES_128_CBC_SHA | |
| * TLS_DHE_RSA_WITH_AES_256_CBC_SHA | | * TLS_DHE_RSA_WITH_AES_256_CBC_SHA | |
| * TLS_RSA_WITH_AES_128_CBC_SHA256 | | * TLS_RSA_WITH_AES_128_CBC_SHA256 | |
| * TLS_RSA_WITH_AES_256_CBC_SHA256 | | * TLS_RSA_WITH_AES_256_CBC_SHA256 | |
| * TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 | | * TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 | |
| * TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 | | * TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 | |
| * TLS_RSA_WITH_AES_128_GCM_SHA256 | | * TLS_RSA_WITH_AES_128_GCM_SHA256 | |
| * TLS_RSA_WITH_AES_256_GCM_SHA384 | | * TLS_RSA_WITH_AES_256_GCM_SHA384 | |
|
| | | * | |
| | | * PEM uses AES for decrypting encrypted keys. | |
| */ | | */ | |
| #define POLARSSL_AES_C | | #define POLARSSL_AES_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_ARC4_C | | * \def POLARSSL_ARC4_C | |
| * | | * | |
| * Enable the ARCFOUR stream cipher. | | * Enable the ARCFOUR stream cipher. | |
| * | | * | |
| * Module: library/arc4.c | | * Module: library/arc4.c | |
| * Caller: library/ssl_tls.c | | * Caller: library/ssl_tls.c | |
| | | | |
| skipping to change at line 489 | | skipping to change at line 501 | |
| * This module provides debugging functions. | | * This module provides debugging functions. | |
| */ | | */ | |
| #define POLARSSL_DEBUG_C | | #define POLARSSL_DEBUG_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_DES_C | | * \def POLARSSL_DES_C | |
| * | | * | |
| * Enable the DES block cipher. | | * Enable the DES block cipher. | |
| * | | * | |
| * Module: library/des.c | | * Module: library/des.c | |
|
| * Caller: library/ssl_tls.c | | * Caller: library/pem.c | |
| | | * library/ssl_tls.c | |
| * | | * | |
| * This module enables the following ciphersuites (if other requisites are | | * This module enables the following ciphersuites (if other requisites are | |
| * enabled as well): | | * enabled as well): | |
| * TLS_RSA_WITH_3DES_EDE_CBC_SHA | | * TLS_RSA_WITH_3DES_EDE_CBC_SHA | |
| * TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | | * TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | |
|
| | | * | |
| | | * PEM uses DES/3DES for decrypting encrypted keys. | |
| */ | | */ | |
| #define POLARSSL_DES_C | | #define POLARSSL_DES_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_DHM_C | | * \def POLARSSL_DHM_C | |
| * | | * | |
| * Enable the Diffie-Hellman-Merkle key exchange. | | * Enable the Diffie-Hellman-Merkle key exchange. | |
| * | | * | |
| * Module: library/dhm.c | | * Module: library/dhm.c | |
| * Caller: library/ssl_cli.c | | * Caller: library/ssl_cli.c | |
| | | | |
| skipping to change at line 624 | | skipping to change at line 639 | |
| * | | * | |
| #define POLARSSL_MD4_C | | #define POLARSSL_MD4_C | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_MD5_C | | * \def POLARSSL_MD5_C | |
| * | | * | |
| * Enable the MD5 hash algorithm | | * Enable the MD5 hash algorithm | |
| * | | * | |
| * Module: library/md5.c | | * Module: library/md5.c | |
|
| * Caller: library/ssl_tls.c | | * Caller: library/pem.c | |
| | | * library/ssl_tls.c | |
| * library/x509parse.c | | * library/x509parse.c | |
| * | | * | |
| * This module is required for SSL/TLS and X.509. | | * This module is required for SSL/TLS and X.509. | |
|
| | | * PEM uses MD5 for decrypting encrypted keys. | |
| */ | | */ | |
| #define POLARSSL_MD5_C | | #define POLARSSL_MD5_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_NET_C | | * \def POLARSSL_NET_C | |
| * | | * | |
| * Enable the TCP/IP networking routines. | | * Enable the TCP/IP networking routines. | |
| * | | * | |
| * Module: library/net.c | | * Module: library/net.c | |
| * Caller: | | * Caller: | |
| | | | |
End of changes. 6 change blocks. |
| 2 lines changed or deleted | | 20 lines changed or added | |
|
| rsa.h | | rsa.h | |
| | | | |
| skipping to change at line 258 | | skipping to change at line 258 | |
| * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | |
| * | | * | |
| * \note The input and output buffers must be large | | * \note The input and output buffers must be large | |
| * enough (eg. 128 bytes if RSA-1024 is used). | | * enough (eg. 128 bytes if RSA-1024 is used). | |
| */ | | */ | |
| int rsa_private( rsa_context *ctx, | | int rsa_private( rsa_context *ctx, | |
| const unsigned char *input, | | const unsigned char *input, | |
| unsigned char *output ); | | unsigned char *output ); | |
| | | | |
| /** | | /** | |
|
| * \brief Add the message padding, then do an RSA operation | | * \brief Generic wrapper to perform a PKCS#1 encryption using the | |
| | | * mode from the context. Add the message padding, then do | |
| | | an | |
| | | * RSA operation. | |
| * | | * | |
| * \param ctx RSA context | | * \param ctx RSA context | |
| * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encodin
g) | | * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encodin
g) | |
| * \param p_rng RNG parameter | | * \param p_rng RNG parameter | |
| * \param mode RSA_PUBLIC or RSA_PRIVATE | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| * \param ilen contains the plaintext length | | * \param ilen contains the plaintext length | |
| * \param input buffer holding the data to be encrypted | | * \param input buffer holding the data to be encrypted | |
| * \param output buffer that will hold the ciphertext | | * \param output buffer that will hold the ciphertext | |
| * | | * | |
| * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | |
| | | | |
| skipping to change at line 281 | | skipping to change at line 283 | |
| * of ctx->N (eg. 128 bytes if RSA-1024 is used). | | * of ctx->N (eg. 128 bytes if RSA-1024 is used). | |
| */ | | */ | |
| int rsa_pkcs1_encrypt( rsa_context *ctx, | | int rsa_pkcs1_encrypt( rsa_context *ctx, | |
| int (*f_rng)(void *, unsigned char *, size_t), | | int (*f_rng)(void *, unsigned char *, size_t), | |
| void *p_rng, | | void *p_rng, | |
| int mode, size_t ilen, | | int mode, size_t ilen, | |
| const unsigned char *input, | | const unsigned char *input, | |
| unsigned char *output ); | | unsigned char *output ); | |
| | | | |
| /** | | /** | |
|
| * \brief Do an RSA operation, then remove the message padding | | * \brief Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRY | |
| | | PT) | |
| | | * | |
| | | * \param ctx RSA context | |
| | | * \param f_rng RNG function (Needed for padding) | |
| | | * \param p_rng RNG parameter | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param ilen contains the plaintext length | |
| | | * \param input buffer holding the data to be encrypted | |
| | | * \param output buffer that will hold the ciphertext | |
| | | * | |
| | | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The output buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used). | |
| | | */ | |
| | | int rsa_rsaes_pkcs1_v15_encrypt( rsa_context *ctx, | |
| | | int (*f_rng)(void *, unsigned char *, size | |
| | | _t), | |
| | | void *p_rng, | |
| | | int mode, size_t ilen, | |
| | | const unsigned char *input, | |
| | | unsigned char *output ); | |
| | | | |
| | | /** | |
| | | * \brief Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYP | |
| | | T) | |
| | | * | |
| | | * \param ctx RSA context | |
| | | * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encodin | |
| | | g) | |
| | | * \param p_rng RNG parameter | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param label buffer holding the custom label to use | |
| | | * \param label_len contains the label length | |
| | | * \param ilen contains the plaintext length | |
| | | * \param input buffer holding the data to be encrypted | |
| | | * \param output buffer that will hold the ciphertext | |
| | | * | |
| | | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The output buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used). | |
| | | */ | |
| | | int rsa_rsaes_oaep_encrypt( rsa_context *ctx, | |
| | | int (*f_rng)(void *, unsigned char *, size_t), | |
| | | void *p_rng, | |
| | | int mode, | |
| | | const unsigned char *label, size_t label_len, | |
| | | size_t ilen, | |
| | | const unsigned char *input, | |
| | | unsigned char *output ); | |
| | | | |
| | | /** | |
| | | * \brief Generic wrapper to perform a PKCS#1 decryption using the | |
| | | * mode from the context. Do an RSA operation, then remove | |
| | | * the message padding | |
| * | | * | |
| * \param ctx RSA context | | * \param ctx RSA context | |
| * \param mode RSA_PUBLIC or RSA_PRIVATE | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| * \param olen will contain the plaintext length | | * \param olen will contain the plaintext length | |
| * \param input buffer holding the encrypted data | | * \param input buffer holding the encrypted data | |
| * \param output buffer that will hold the plaintext | | * \param output buffer that will hold the plaintext | |
| * \param output_max_len maximum length of the output buffer | | * \param output_max_len maximum length of the output buffer | |
| * | | * | |
| * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | |
| * | | * | |
| | | | |
| skipping to change at line 303 | | skipping to change at line 357 | |
| * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise | | * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise | |
| * an error is thrown. | | * an error is thrown. | |
| */ | | */ | |
| int rsa_pkcs1_decrypt( rsa_context *ctx, | | int rsa_pkcs1_decrypt( rsa_context *ctx, | |
| int mode, size_t *olen, | | int mode, size_t *olen, | |
| const unsigned char *input, | | const unsigned char *input, | |
| unsigned char *output, | | unsigned char *output, | |
| size_t output_max_len ); | | size_t output_max_len ); | |
| | | | |
| /** | | /** | |
|
| * \brief Do a private RSA to sign a message digest | | * \brief Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRY | |
| | | PT) | |
| | | * | |
| | | * \param ctx RSA context | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param olen will contain the plaintext length | |
| | | * \param input buffer holding the encrypted data | |
| | | * \param output buffer that will hold the plaintext | |
| | | * \param output_max_len maximum length of the output buffer | |
| | | * | |
| | | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The output buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise | |
| | | * an error is thrown. | |
| | | */ | |
| | | int rsa_rsaes_pkcs1_v15_decrypt( rsa_context *ctx, | |
| | | int mode, size_t *olen, | |
| | | const unsigned char *input, | |
| | | unsigned char *output, | |
| | | size_t output_max_len ); | |
| | | | |
| | | /** | |
| | | * \brief Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYP | |
| | | T) | |
| | | * | |
| | | * \param ctx RSA context | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param label buffer holding the custom label to use | |
| | | * \param label_len contains the label length | |
| | | * \param olen will contain the plaintext length | |
| | | * \param input buffer holding the encrypted data | |
| | | * \param output buffer that will hold the plaintext | |
| | | * \param output_max_len maximum length of the output buffer | |
| | | * | |
| | | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The output buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise | |
| | | * an error is thrown. | |
| | | */ | |
| | | int rsa_rsaes_oaep_decrypt( rsa_context *ctx, | |
| | | int mode, | |
| | | const unsigned char *label, size_t label_len, | |
| | | size_t *olen, | |
| | | const unsigned char *input, | |
| | | unsigned char *output, | |
| | | size_t output_max_len ); | |
| | | | |
| | | /** | |
| | | * \brief Generic wrapper to perform a PKCS#1 signature using the | |
| | | * mode from the context. Do a private RSA operation to sig | |
| | | n | |
| | | * a message digest | |
| * | | * | |
| * \param ctx RSA context | | * \param ctx RSA context | |
| * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding) | | * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding) | |
| * \param p_rng RNG parameter | | * \param p_rng RNG parameter | |
| * \param mode RSA_PUBLIC or RSA_PRIVATE | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,
384,512} | | * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,
384,512} | |
| * \param hashlen message digest length (for SIG_RSA_RAW only) | | * \param hashlen message digest length (for SIG_RSA_RAW only) | |
| * \param hash buffer holding the message digest | | * \param hash buffer holding the message digest | |
| * \param sig buffer that will hold the ciphertext | | * \param sig buffer that will hold the ciphertext | |
| * | | * | |
| | | | |
| skipping to change at line 336 | | skipping to change at line 440 | |
| int rsa_pkcs1_sign( rsa_context *ctx, | | int rsa_pkcs1_sign( rsa_context *ctx, | |
| int (*f_rng)(void *, unsigned char *, size_t), | | int (*f_rng)(void *, unsigned char *, size_t), | |
| void *p_rng, | | void *p_rng, | |
| int mode, | | int mode, | |
| int hash_id, | | int hash_id, | |
| unsigned int hashlen, | | unsigned int hashlen, | |
| const unsigned char *hash, | | const unsigned char *hash, | |
| unsigned char *sig ); | | unsigned char *sig ); | |
| | | | |
| /** | | /** | |
|
| * \brief Do a public RSA and check the message digest | | * \brief Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN) | |
| | | * | |
| | | * \param ctx RSA context | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256, | |
| | | 384,512} | |
| | | * \param hashlen message digest length (for SIG_RSA_RAW only) | |
| | | * \param hash buffer holding the message digest | |
| | | * \param sig buffer that will hold the ciphertext | |
| | | * | |
| | | * \return 0 if the signing operation was successful, | |
| | | * or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The "sig" buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used). | |
| | | */ | |
| | | int rsa_rsassa_pkcs1_v15_sign( rsa_context *ctx, | |
| | | int mode, | |
| | | int hash_id, | |
| | | unsigned int hashlen, | |
| | | const unsigned char *hash, | |
| | | unsigned char *sig ); | |
| | | | |
| | | /** | |
| | | * \brief Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN) | |
| | | * | |
| | | * \param ctx RSA context | |
| | | * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding) | |
| | | * \param p_rng RNG parameter | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256, | |
| | | 384,512} | |
| | | * \param hashlen message digest length (for SIG_RSA_RAW only) | |
| | | * \param hash buffer holding the message digest | |
| | | * \param sig buffer that will hold the ciphertext | |
| | | * | |
| | | * \return 0 if the signing operation was successful, | |
| | | * or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The "sig" buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used). | |
| | | * | |
| | | * \note In case of PKCS#1 v2.1 encoding keep in mind that | |
| | | * the hash_id in the RSA context is the one used for the | |
| | | * encoding. hash_id in the function call is the type of ha | |
| | | sh | |
| | | * that is encoded. According to RFC 3447 it is advised to | |
| | | * keep both hashes the same. | |
| | | */ | |
| | | int rsa_rsassa_pss_sign( rsa_context *ctx, | |
| | | int (*f_rng)(void *, unsigned char *, size_t), | |
| | | void *p_rng, | |
| | | int mode, | |
| | | int hash_id, | |
| | | unsigned int hashlen, | |
| | | const unsigned char *hash, | |
| | | unsigned char *sig ); | |
| | | | |
| | | /** | |
| | | * \brief Generic wrapper to perform a PKCS#1 verification using t | |
| | | he | |
| | | * mode from the context. Do a public RSA operation and che | |
| | | ck | |
| | | * the message digest | |
| * | | * | |
| * \param ctx points to an RSA public key | | * \param ctx points to an RSA public key | |
| * \param mode RSA_PUBLIC or RSA_PRIVATE | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,
384,512} | | * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,
384,512} | |
| * \param hashlen message digest length (for SIG_RSA_RAW only) | | * \param hashlen message digest length (for SIG_RSA_RAW only) | |
| * \param hash buffer holding the message digest | | * \param hash buffer holding the message digest | |
| * \param sig buffer holding the ciphertext | | * \param sig buffer holding the ciphertext | |
| * | | * | |
| * \return 0 if the verify operation was successful, | | * \return 0 if the verify operation was successful, | |
| * or an POLARSSL_ERR_RSA_XXX error code | | * or an POLARSSL_ERR_RSA_XXX error code | |
| | | | |
| skipping to change at line 365 | | skipping to change at line 527 | |
| * keep both hashes the same. | | * keep both hashes the same. | |
| */ | | */ | |
| int rsa_pkcs1_verify( rsa_context *ctx, | | int rsa_pkcs1_verify( rsa_context *ctx, | |
| int mode, | | int mode, | |
| int hash_id, | | int hash_id, | |
| unsigned int hashlen, | | unsigned int hashlen, | |
| const unsigned char *hash, | | const unsigned char *hash, | |
| unsigned char *sig ); | | unsigned char *sig ); | |
| | | | |
| /** | | /** | |
|
| | | * \brief Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VE | |
| | | RIFY) | |
| | | * | |
| | | * \param ctx points to an RSA public key | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256, | |
| | | 384,512} | |
| | | * \param hashlen message digest length (for SIG_RSA_RAW only) | |
| | | * \param hash buffer holding the message digest | |
| | | * \param sig buffer holding the ciphertext | |
| | | * | |
| | | * \return 0 if the verify operation was successful, | |
| | | * or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The "sig" buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used). | |
| | | */ | |
| | | int rsa_rsassa_pkcs1_v15_verify( rsa_context *ctx, | |
| | | int mode, | |
| | | int hash_id, | |
| | | unsigned int hashlen, | |
| | | const unsigned char *hash, | |
| | | unsigned char *sig ); | |
| | | | |
| | | /** | |
| | | * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIF | |
| | | Y) | |
| | | * \brief Do a public RSA and check the message digest | |
| | | * | |
| | | * \param ctx points to an RSA public key | |
| | | * \param mode RSA_PUBLIC or RSA_PRIVATE | |
| | | * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256, | |
| | | 384,512} | |
| | | * \param hashlen message digest length (for SIG_RSA_RAW only) | |
| | | * \param hash buffer holding the message digest | |
| | | * \param sig buffer holding the ciphertext | |
| | | * | |
| | | * \return 0 if the verify operation was successful, | |
| | | * or an POLARSSL_ERR_RSA_XXX error code | |
| | | * | |
| | | * \note The "sig" buffer must be as large as the size | |
| | | * of ctx->N (eg. 128 bytes if RSA-1024 is used). | |
| | | * | |
| | | * \note In case of PKCS#1 v2.1 encoding keep in mind that | |
| | | * the hash_id in the RSA context is the one used for the | |
| | | * verification. hash_id in the function call is the type o | |
| | | f hash | |
| | | * that is verified. According to RFC 3447 it is advised to | |
| | | * keep both hashes the same. | |
| | | */ | |
| | | int rsa_rsassa_pss_verify( rsa_context *ctx, | |
| | | int mode, | |
| | | int hash_id, | |
| | | unsigned int hashlen, | |
| | | const unsigned char *hash, | |
| | | unsigned char *sig ); | |
| | | | |
| | | /** | |
| * \brief Free the components of an RSA key | | * \brief Free the components of an RSA key | |
| * | | * | |
| * \param ctx RSA Context to free | | * \param ctx RSA Context to free | |
| */ | | */ | |
| void rsa_free( rsa_context *ctx ); | | void rsa_free( rsa_context *ctx ); | |
| | | | |
| /** | | /** | |
| * \brief Checkup routine | | * \brief Checkup routine | |
| * | | * | |
| * \return 0 if successful, or 1 if the test failed | | * \return 0 if successful, or 1 if the test failed | |
| | | | |
End of changes. 5 change blocks. |
| 4 lines changed or deleted | | 237 lines changed or added | |
|