Added AES+GHASH implementation using AES-NI opcodes; also ARM-Thumb assembly for faster Montgomery multiplication on Cortex-M0+. Added selection functions for "default" implementations.
This commit is contained in:
parent
556e525d62
commit
5f045c7599
58 changed files with 3012 additions and 395 deletions
36
src/ssl/ssl_client_default_rsapub.c
Normal file
36
src/ssl/ssl_client_default_rsapub.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_client_set_default_rsapub(br_ssl_client_context *cc)
|
||||
{
|
||||
#if BR_LOMUL
|
||||
br_ssl_client_set_rsapub(cc, &br_rsa_i15_public);
|
||||
#else
|
||||
br_ssl_client_set_rsapub(cc, &br_rsa_i31_public);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -125,13 +125,13 @@ br_ssl_client_init_full(br_ssl_client_context *cc,
|
|||
*/
|
||||
br_ssl_engine_set_suites(&cc->eng, suites,
|
||||
(sizeof suites) / (sizeof suites[0]));
|
||||
br_ssl_client_set_rsapub(cc, &br_rsa_i31_public);
|
||||
br_ssl_engine_set_rsavrfy(&cc->eng, &br_rsa_i31_pkcs1_vrfy);
|
||||
br_ssl_engine_set_ec(&cc->eng, &br_ec_all_m15);
|
||||
br_ssl_engine_set_ecdsa(&cc->eng, &br_ecdsa_i31_vrfy_asn1);
|
||||
br_x509_minimal_set_rsa(xc, &br_rsa_i31_pkcs1_vrfy);
|
||||
br_ssl_client_set_default_rsapub(cc);
|
||||
br_ssl_engine_set_default_rsavrfy(&cc->eng);
|
||||
br_ssl_engine_set_default_ecdsa(&cc->eng);
|
||||
br_x509_minimal_set_rsa(xc, br_ssl_engine_get_rsavrfy(&cc->eng));
|
||||
br_x509_minimal_set_ecdsa(xc,
|
||||
&br_ec_all_m15, &br_ecdsa_i31_vrfy_asn1);
|
||||
br_ssl_engine_get_ec(&cc->eng),
|
||||
br_ssl_engine_get_ecdsa(&cc->eng));
|
||||
|
||||
/*
|
||||
* Set supported hash functions, for the SSL engine and for the
|
||||
|
|
@ -158,47 +158,11 @@ br_ssl_client_init_full(br_ssl_client_context *cc,
|
|||
br_ssl_engine_set_prf_sha384(&cc->eng, &br_tls12_sha384_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption. We use the "default" implementations
|
||||
* (fastest among constant-time implementations).
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_cbc(&cc->eng,
|
||||
&br_aes_ct64_cbcenc_vtable,
|
||||
&br_aes_ct64_cbcdec_vtable);
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_cbc(&cc->eng,
|
||||
&br_aes_ct_cbcenc_vtable,
|
||||
&br_aes_ct_cbcdec_vtable);
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
br_ssl_engine_set_des_cbc(&cc->eng,
|
||||
&br_des_ct_cbcenc_vtable,
|
||||
&br_des_ct_cbcdec_vtable);
|
||||
br_ssl_engine_set_chacha20(&cc->eng,
|
||||
&br_chacha20_ct_run);
|
||||
br_ssl_engine_set_poly1305(&cc->eng,
|
||||
&br_poly1305_ctmul_run);
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM).
|
||||
*/
|
||||
br_ssl_engine_set_cbc(&cc->eng,
|
||||
&br_sslrec_in_cbc_vtable,
|
||||
&br_sslrec_out_cbc_vtable);
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_chapol(&cc->eng,
|
||||
&br_sslrec_in_chapol_vtable,
|
||||
&br_sslrec_out_chapol_vtable);
|
||||
br_ssl_engine_set_default_aes_cbc(&cc->eng);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
br_ssl_engine_set_default_des_cbc(&cc->eng);
|
||||
br_ssl_engine_set_default_chapol(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
56
src/ssl/ssl_engine_default_aescbc.c
Normal file
56
src/ssl/ssl_engine_default_aescbc.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_engine_set_default_aes_cbc(br_ssl_engine_context *cc)
|
||||
{
|
||||
#if BR_AES_X86NI
|
||||
const br_block_cbcenc_class *ienc;
|
||||
const br_block_cbcdec_class *idec;
|
||||
#endif
|
||||
|
||||
br_ssl_engine_set_cbc(cc,
|
||||
&br_sslrec_in_cbc_vtable,
|
||||
&br_sslrec_out_cbc_vtable);
|
||||
#if BR_AES_X86NI
|
||||
ienc = br_aes_x86ni_cbcenc_get_vtable();
|
||||
idec = br_aes_x86ni_cbcdec_get_vtable();
|
||||
if (ienc != NULL && idec != NULL) {
|
||||
br_ssl_engine_set_aes_cbc(cc, ienc, idec);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_cbc(cc,
|
||||
&br_aes_ct64_cbcenc_vtable,
|
||||
&br_aes_ct64_cbcdec_vtable);
|
||||
#else
|
||||
br_ssl_engine_set_aes_cbc(cc,
|
||||
&br_aes_ct_cbcenc_vtable,
|
||||
&br_aes_ct_cbcdec_vtable);
|
||||
#endif
|
||||
}
|
||||
71
src/ssl/ssl_engine_default_aesgcm.c
Normal file
71
src/ssl/ssl_engine_default_aesgcm.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_engine_set_default_aes_gcm(br_ssl_engine_context *cc)
|
||||
{
|
||||
#if BR_AES_X86NI
|
||||
const br_block_ctr_class *ictr;
|
||||
br_ghash ighash;
|
||||
#endif
|
||||
|
||||
br_ssl_engine_set_gcm(cc,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
#if BR_AES_X86NI
|
||||
ictr = br_aes_x86ni_ctr_get_vtable();
|
||||
if (ictr != NULL) {
|
||||
br_ssl_engine_set_aes_ctr(cc, ictr);
|
||||
} else {
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_ctr(cc, &br_aes_ct64_ctr_vtable);
|
||||
#else
|
||||
br_ssl_engine_set_aes_ctr(cc, &br_aes_ct_ctr_vtable);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_ctr(cc, &br_aes_ct64_ctr_vtable);
|
||||
#else
|
||||
br_ssl_engine_set_aes_ctr(cc, &br_aes_ct_ctr_vtable);
|
||||
#endif
|
||||
#endif
|
||||
#if BR_AES_X86NI
|
||||
ighash = br_ghash_pclmul_get();
|
||||
if (ighash != 0) {
|
||||
br_ssl_engine_set_ghash(cc, ighash);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if BR_LOMUL
|
||||
br_ssl_engine_set_ghash(cc, &br_ghash_ctmul32);
|
||||
#elif BR_64
|
||||
br_ssl_engine_set_ghash(cc, &br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_ghash(cc, &br_ghash_ctmul);
|
||||
#endif
|
||||
}
|
||||
40
src/ssl/ssl_engine_default_chapol.c
Normal file
40
src/ssl/ssl_engine_default_chapol.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_engine_set_default_chapol(br_ssl_engine_context *cc)
|
||||
{
|
||||
br_ssl_engine_set_chapol(cc,
|
||||
&br_sslrec_in_chapol_vtable,
|
||||
&br_sslrec_out_chapol_vtable);
|
||||
br_ssl_engine_set_chacha20(cc, &br_chacha20_ct_run);
|
||||
#if BR_LOMUL
|
||||
br_ssl_engine_set_poly1305(cc, &br_poly1305_ctmul32_run);
|
||||
#else
|
||||
br_ssl_engine_set_poly1305(cc, &br_poly1305_ctmul_run);
|
||||
#endif
|
||||
}
|
||||
37
src/ssl/ssl_engine_default_descbc.c
Normal file
37
src/ssl/ssl_engine_default_descbc.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_engine_set_default_des_cbc(br_ssl_engine_context *cc)
|
||||
{
|
||||
br_ssl_engine_set_cbc(cc,
|
||||
&br_sslrec_in_cbc_vtable,
|
||||
&br_sslrec_out_cbc_vtable);
|
||||
br_ssl_engine_set_des_cbc(cc,
|
||||
&br_des_ct_cbcenc_vtable,
|
||||
&br_des_ct_cbcdec_vtable);
|
||||
}
|
||||
36
src/ssl/ssl_engine_default_ec.c
Normal file
36
src/ssl/ssl_engine_default_ec.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_engine_set_default_ec(br_ssl_engine_context *cc)
|
||||
{
|
||||
#if BR_LOMUL
|
||||
br_ssl_engine_set_ec(cc, &br_ec_all_m15);
|
||||
#else
|
||||
br_ssl_engine_set_ec(cc, &br_ec_all_m31);
|
||||
#endif
|
||||
}
|
||||
38
src/ssl/ssl_engine_default_ecdsa.c
Normal file
38
src/ssl/ssl_engine_default_ecdsa.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_engine_set_default_ecdsa(br_ssl_engine_context *cc)
|
||||
{
|
||||
#if BR_LOMUL
|
||||
br_ssl_engine_set_ec(cc, &br_ec_all_m15);
|
||||
br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i15_vrfy_asn1);
|
||||
#else
|
||||
br_ssl_engine_set_ec(cc, &br_ec_all_m31);
|
||||
br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i31_vrfy_asn1);
|
||||
#endif
|
||||
}
|
||||
36
src/ssl/ssl_engine_default_rsavrfy.c
Normal file
36
src/ssl/ssl_engine_default_rsavrfy.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Thomas Pornin <pornin@bolet.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "inner.h"
|
||||
|
||||
/* see bearssl_ssl.h */
|
||||
void
|
||||
br_ssl_engine_set_default_rsavrfy(br_ssl_engine_context *cc)
|
||||
{
|
||||
#if BR_LOMUL
|
||||
br_ssl_engine_set_rsavrfy(cc, &br_rsa_i15_pkcs1_vrfy);
|
||||
#else
|
||||
br_ssl_engine_set_rsavrfy(cc, &br_rsa_i31_pkcs1_vrfy);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ br_ssl_server_init_full_ec(br_ssl_server_context *cc,
|
|||
*/
|
||||
br_ssl_engine_set_suites(&cc->eng, suites,
|
||||
(sizeof suites) / (sizeof suites[0]));
|
||||
br_ssl_engine_set_ec(&cc->eng, &br_ec_all_m15);
|
||||
br_ssl_engine_set_default_ec(&cc->eng);
|
||||
|
||||
/*
|
||||
* Set the "server policy": handler for the certificate chain
|
||||
|
|
@ -108,7 +108,13 @@ br_ssl_server_init_full_ec(br_ssl_server_context *cc,
|
|||
br_ssl_server_set_single_ec(cc, chain, chain_len, sk,
|
||||
BR_KEYTYPE_KEYX | BR_KEYTYPE_SIGN,
|
||||
cert_issuer_key_type,
|
||||
&br_ec_all_m15, br_ecdsa_i31_sign_asn1);
|
||||
br_ssl_engine_get_ec(&cc->eng),
|
||||
#if BR_LOMUL
|
||||
br_ecdsa_i15_sign_asn1
|
||||
#else
|
||||
br_ecdsa_i31_sign_asn1
|
||||
#endif
|
||||
);
|
||||
|
||||
/*
|
||||
* Set supported hash functions.
|
||||
|
|
@ -128,47 +134,10 @@ br_ssl_server_init_full_ec(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha384(&cc->eng, &br_tls12_sha384_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_cbc(&cc->eng,
|
||||
&br_aes_ct64_cbcenc_vtable,
|
||||
&br_aes_ct64_cbcdec_vtable);
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_cbc(&cc->eng,
|
||||
&br_aes_ct_cbcenc_vtable,
|
||||
&br_aes_ct_cbcdec_vtable);
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
br_ssl_engine_set_des_cbc(&cc->eng,
|
||||
&br_des_ct_cbcenc_vtable,
|
||||
&br_des_ct_cbcdec_vtable);
|
||||
br_ssl_engine_set_chacha20(&cc->eng,
|
||||
&br_chacha20_ct_run);
|
||||
br_ssl_engine_set_poly1305(&cc->eng,
|
||||
&br_poly1305_ctmul_run);
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM).
|
||||
*/
|
||||
br_ssl_engine_set_cbc(&cc->eng,
|
||||
&br_sslrec_in_cbc_vtable,
|
||||
&br_sslrec_out_cbc_vtable);
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_chapol(&cc->eng,
|
||||
&br_sslrec_in_chapol_vtable,
|
||||
&br_sslrec_out_chapol_vtable);
|
||||
br_ssl_engine_set_default_aes_cbc(&cc->eng);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
br_ssl_engine_set_default_des_cbc(&cc->eng);
|
||||
br_ssl_engine_set_default_chapol(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ br_ssl_server_init_full_rsa(br_ssl_server_context *cc,
|
|||
*/
|
||||
br_ssl_engine_set_suites(&cc->eng, suites,
|
||||
(sizeof suites) / (sizeof suites[0]));
|
||||
br_ssl_engine_set_ec(&cc->eng, &br_ec_all_m15);
|
||||
br_ssl_engine_set_default_ec(&cc->eng);
|
||||
|
||||
/*
|
||||
* Set the "server policy": handler for the certificate chain
|
||||
|
|
@ -97,7 +97,12 @@ br_ssl_server_init_full_rsa(br_ssl_server_context *cc,
|
|||
*/
|
||||
br_ssl_server_set_single_rsa(cc, chain, chain_len, sk,
|
||||
BR_KEYTYPE_KEYX | BR_KEYTYPE_SIGN,
|
||||
br_rsa_i31_private, br_rsa_i31_pkcs1_sign);
|
||||
#if BR_LOMUL
|
||||
br_rsa_i15_private, br_rsa_i15_pkcs1_sign
|
||||
#else
|
||||
br_rsa_i31_private, br_rsa_i31_pkcs1_sign
|
||||
#endif
|
||||
);
|
||||
|
||||
/*
|
||||
* Set supported hash functions.
|
||||
|
|
@ -117,47 +122,10 @@ br_ssl_server_init_full_rsa(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha384(&cc->eng, &br_tls12_sha384_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_cbc(&cc->eng,
|
||||
&br_aes_ct64_cbcenc_vtable,
|
||||
&br_aes_ct64_cbcdec_vtable);
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_cbc(&cc->eng,
|
||||
&br_aes_ct_cbcenc_vtable,
|
||||
&br_aes_ct_cbcdec_vtable);
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
br_ssl_engine_set_des_cbc(&cc->eng,
|
||||
&br_des_ct_cbcenc_vtable,
|
||||
&br_des_ct_cbcdec_vtable);
|
||||
br_ssl_engine_set_chacha20(&cc->eng,
|
||||
&br_chacha20_ct_run);
|
||||
br_ssl_engine_set_poly1305(&cc->eng,
|
||||
&br_poly1305_ctmul_run);
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM, ChaCha20).
|
||||
*/
|
||||
br_ssl_engine_set_cbc(&cc->eng,
|
||||
&br_sslrec_in_cbc_vtable,
|
||||
&br_sslrec_out_cbc_vtable);
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_chapol(&cc->eng,
|
||||
&br_sslrec_in_chapol_vtable,
|
||||
&br_sslrec_out_chapol_vtable);
|
||||
br_ssl_engine_set_default_aes_cbc(&cc->eng);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
br_ssl_engine_set_default_des_cbc(&cc->eng);
|
||||
br_ssl_engine_set_default_chapol(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,18 +65,7 @@ br_ssl_server_init_mine2c(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha256(&cc->eng, &br_tls12_sha256_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
br_ssl_engine_set_chacha20(&cc->eng,
|
||||
&br_chacha20_ct_run);
|
||||
br_ssl_engine_set_poly1305(&cc->eng,
|
||||
&br_poly1305_ctmul_run);
|
||||
|
||||
/*
|
||||
* Set the SSL record engines.
|
||||
*/
|
||||
br_ssl_engine_set_chapol(&cc->eng,
|
||||
&br_sslrec_in_chapol_vtable,
|
||||
&br_sslrec_out_chapol_vtable);
|
||||
br_ssl_engine_set_default_chapol(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,28 +65,7 @@ br_ssl_server_init_mine2g(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha256(&cc->eng, &br_tls12_sha256_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM).
|
||||
*/
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,21 +65,7 @@ br_ssl_server_init_minf2c(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha256(&cc->eng, &br_tls12_sha256_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
br_ssl_engine_set_chacha20(&cc->eng,
|
||||
&br_chacha20_ct_run);
|
||||
br_ssl_engine_set_poly1305(&cc->eng,
|
||||
&br_poly1305_ctmul_run);
|
||||
|
||||
/*
|
||||
* Set the SSL record engines.
|
||||
*/
|
||||
br_ssl_engine_set_chapol(&cc->eng,
|
||||
&br_sslrec_in_chapol_vtable,
|
||||
&br_sslrec_out_chapol_vtable);
|
||||
br_ssl_engine_set_default_chapol(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,28 +65,7 @@ br_ssl_server_init_minf2g(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha256(&cc->eng, &br_tls12_sha256_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM).
|
||||
*/
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,28 +64,7 @@ br_ssl_server_init_minr2g(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha256(&cc->eng, &br_tls12_sha256_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM).
|
||||
*/
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,28 +64,7 @@ br_ssl_server_init_minu2g(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha256(&cc->eng, &br_tls12_sha256_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM).
|
||||
*/
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,28 +64,7 @@ br_ssl_server_init_minv2g(br_ssl_server_context *cc,
|
|||
br_ssl_engine_set_prf_sha256(&cc->eng, &br_tls12_sha256_prf);
|
||||
|
||||
/*
|
||||
* Symmetric encryption. We use the "constant-time"
|
||||
* implementations, which are the safest.
|
||||
*
|
||||
* On architectures detected as "64-bit", use the 64-bit
|
||||
* versions (aes_ct64, ghash_ctmul64).
|
||||
* Symmetric encryption.
|
||||
*/
|
||||
#if BR_64
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct64_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul64);
|
||||
#else
|
||||
br_ssl_engine_set_aes_ctr(&cc->eng,
|
||||
&br_aes_ct_ctr_vtable);
|
||||
br_ssl_engine_set_ghash(&cc->eng,
|
||||
&br_ghash_ctmul);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the SSL record engines (CBC, GCM).
|
||||
*/
|
||||
br_ssl_engine_set_gcm(&cc->eng,
|
||||
&br_sslrec_in_gcm_vtable,
|
||||
&br_sslrec_out_gcm_vtable);
|
||||
br_ssl_engine_set_default_aes_gcm(&cc->eng);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue