Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
external
mbedtls
Commits
fd5164e2
Commit
fd5164e2
authored
Jul 11, 2013
by
Manuel Pégourié-Gonnard
Committed by
Paul Bakker
Jul 17, 2013
Browse files
Fix some more ifdef's RSA/EC, in pk and debug
parent
ab2d9836
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/polarssl/pk.h
View file @
fd5164e2
...
...
@@ -44,7 +44,7 @@
* before using this macro!
*/
#define pk_rsa( pk ) ( (rsa_context *) (pk).data )
#endif
#endif
/* POLARSSL_RSA_C */
#if defined(POLARSSL_ECP_C)
/**
...
...
@@ -54,7 +54,7 @@
* before using this macro!
*/
#define pk_ec( pk ) ( (ecp_keypair *) (pk).data )
#endif
#endif
/* POLARSSL_ECP_C */
#ifdef __cplusplus
...
...
@@ -120,7 +120,7 @@ int pk_set_type( pk_context *ctx, pk_type_t type );
* POLARSSL_ERR_PK_TYPE_MISMATCH if ctx was not empty.
*/
int
pk_wrap_rsa
(
pk_context
*
ctx
,
const
rsa_context
*
rsa
);
#endif
#endif
/* POLARSSL_RSA_C */
#ifdef __cplusplus
}
...
...
library/debug.c
View file @
fd5164e2
...
...
@@ -250,27 +250,25 @@ void debug_print_crt( const ssl_context *ssl, int level,
str
[
maxlen
]
=
'\0'
;
ssl
->
f_dbg
(
ssl
->
p_dbg
,
level
,
str
);
switch
(
crt
->
pk
.
type
)
#if defined(POLARSSL_RSA_C)
if
(
crt
->
pk
.
type
==
POLARSSL_PK_RSA
)
{
case
POLARSSL_PK_NONE
:
case
POLARSSL_PK_ECDSA
:
debug_print_msg
(
ssl
,
level
,
file
,
line
,
"crt->pk.type is not valid"
);
break
;
case
POLARSSL_PK_RSA
:
debug_print_mpi
(
ssl
,
level
,
file
,
line
,
"crt->rsa.N"
,
&
pk_rsa
(
crt
->
pk
)
->
N
);
debug_print_mpi
(
ssl
,
level
,
file
,
line
,
"crt->rsa.E"
,
&
pk_rsa
(
crt
->
pk
)
->
E
);
break
;
case
POLARSSL_PK_ECKEY
:
case
POLARSSL_PK_ECKEY_DH
:
debug_print_ecp
(
ssl
,
level
,
file
,
line
,
"crt->eckey.Q"
,
&
pk_ec
(
crt
->
pk
)
->
Q
);
break
;
}
debug_print_mpi
(
ssl
,
level
,
file
,
line
,
"crt->rsa.N"
,
&
pk_rsa
(
crt
->
pk
)
->
N
);
debug_print_mpi
(
ssl
,
level
,
file
,
line
,
"crt->rsa.E"
,
&
pk_rsa
(
crt
->
pk
)
->
E
);
}
else
#endif
/* POLARSSL_RSA_C */
#if defined(POLARSSL_ECP_C)
if
(
crt
->
pk
.
type
==
POLARSSL_PK_ECKEY
||
crt
->
pk
.
type
==
POLARSSL_PK_ECKEY_DH
)
{
debug_print_ecp
(
ssl
,
level
,
file
,
line
,
"crt->eckey.Q"
,
&
pk_ec
(
crt
->
pk
)
->
Q
);
}
else
#endif
/* POLARSSL_ECP_C */
debug_print_msg
(
ssl
,
level
,
file
,
line
,
"crt->pk.type is not valid"
);
crt
=
crt
->
next
;
}
...
...
library/pk.c
View file @
fd5164e2
...
...
@@ -60,29 +60,23 @@ void pk_free( pk_context *ctx )
if
(
ctx
==
NULL
)
return
;
switch
(
ctx
->
type
)
{
case
POLARSSL_PK_NONE
:
break
;
#if defined(POLARSSL_RSA_C)
case
POLARSSL_PK_RSA
:
rsa_free
(
ctx
->
data
);
break
;
if
(
ctx
->
type
==
POLARSSL_PK_RSA
)
rsa_free
(
ctx
->
data
);
else
#endif
#if defined(POLARSSL_ECP_C)
case
POLARSSL_PK_ECKEY
:
case
POLARSSL_PK_ECKEY_DH
:
ecp_keypair_free
(
ctx
->
data
);
break
;
if
(
ctx
->
type
==
POLARSSL_PK_ECKEY
||
ctx
->
type
==
POLARSSL_PK_ECKEY_DH
)
ecp_keypair_free
(
ctx
->
data
);
else
#endif
#if defined(POLARSSL_ECDSA_C)
case
POLARSSL_PK_ECDSA
:
ecdsa_free
(
ctx
->
data
);
break
;
if
(
ctx
->
type
==
POLARSSL_PK_ECDSA
)
ecdsa_free
(
ctx
->
data
);
else
#endif
{
;
/* guard for the else's above */
}
if
(
!
ctx
->
dont_free
)
...
...
@@ -97,7 +91,7 @@ void pk_free( pk_context *ctx )
*/
int
pk_set_type
(
pk_context
*
ctx
,
pk_type_t
type
)
{
size_t
size
=
0
;
size_t
size
;
if
(
ctx
->
type
==
type
)
return
(
0
);
...
...
@@ -105,30 +99,22 @@ int pk_set_type( pk_context *ctx, pk_type_t type )
if
(
ctx
->
type
!=
POLARSSL_PK_NONE
)
return
(
POLARSSL_ERR_PK_TYPE_MISMATCH
);
switch
(
type
)
{
#if defined(POLARSSL_RSA_C)
case
POLARSSL_PK_RSA
:
size
=
sizeof
(
rsa_context
);
break
;
if
(
type
==
POLARSSL_PK_RSA
)
size
=
sizeof
(
rsa_context
);
else
#endif
#if defined(POLARSSL_ECP_C)
case
POLARSSL_PK_ECKEY
:
case
POLARSSL_PK_ECKEY_DH
:
size
=
sizeof
(
ecp_keypair
);
break
;
if
(
type
==
POLARSSL_PK_ECKEY
||
type
==
POLARSSL_PK_ECKEY_DH
)
size
=
sizeof
(
ecp_keypair
);
else
#endif
#if defined(POLARSSL_ECDSA_C)
case
POLARSSL_PK_ECDSA
:
size
=
sizeof
(
ecdsa_context
);
break
;
if
(
type
==
POLARSSL_PK_ECDSA
)
size
=
sizeof
(
ecdsa_context
);
else
#endif
case
POLARSSL_PK_NONE
:
;
/* Cannot happen, but the compiler doesn't know */
}
size
=
0
;
/* should never be executed */
if
(
(
ctx
->
data
=
malloc
(
size
)
)
==
NULL
)
return
(
POLARSSL_ERR_PK_MALLOC_FAILED
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment