@@ -453,7 +453,7 @@ int crypto_ec_point_cmp(const struct crypto_ec *e,
453453 (const mbedtls_ecp_point * ) b );
454454}
455455
456- int crypto_key_compare (struct crypto_key * key1 , struct crypto_key * key2 )
456+ int crypto_ec_key_compare (struct crypto_ec_key * key1 , struct crypto_ec_key * key2 )
457457{
458458 int ret = 0 ;
459459 mbedtls_entropy_context entropy ;
@@ -488,7 +488,7 @@ void crypto_debug_print_point(const char *title, struct crypto_ec *e,
488488 wpa_hexdump (MSG_ERROR , "y:" , y , 32 );
489489}
490490
491- static struct crypto_key * crypto_alloc_key (void )
491+ static struct crypto_ec_key * crypto_alloc_key (void )
492492{
493493 mbedtls_pk_context * key = os_malloc (sizeof (* key ));
494494
@@ -498,14 +498,14 @@ static struct crypto_key *crypto_alloc_key(void)
498498 }
499499 mbedtls_pk_init (key );
500500
501- return (struct crypto_key * )key ;
501+ return (struct crypto_ec_key * )key ;
502502}
503503
504- struct crypto_key * crypto_ec_set_pubkey_point (const struct crypto_ec_group * group ,
504+ struct crypto_ec_key * crypto_ec_set_pubkey_point (const struct crypto_ec_group * group ,
505505 const u8 * buf , size_t len )
506506{
507507 mbedtls_ecp_point * point = NULL ;
508- struct crypto_key * pkey = NULL ;
508+ struct crypto_ec_key * pkey = NULL ;
509509 int ret ;
510510 mbedtls_pk_context * key = (mbedtls_pk_context * )crypto_alloc_key ();
511511 mbedtls_ecp_group * ecp_grp = (mbedtls_ecp_group * )group ;
@@ -543,7 +543,7 @@ struct crypto_key * crypto_ec_set_pubkey_point(const struct crypto_ec_group *gro
543543 mbedtls_ecp_copy (& mbedtls_pk_ec (* key )-> MBEDTLS_PRIVATE (Q ), point );
544544 mbedtls_ecp_group_load (& mbedtls_pk_ec (* key )-> MBEDTLS_PRIVATE (grp ), ecp_grp -> id );
545545
546- pkey = (struct crypto_key * )key ;
546+ pkey = (struct crypto_ec_key * )key ;
547547 crypto_ec_point_deinit ((struct crypto_ec_point * )point , 0 );
548548 return pkey ;
549549fail :
@@ -557,21 +557,21 @@ struct crypto_key * crypto_ec_set_pubkey_point(const struct crypto_ec_group *gro
557557 return pkey ;
558558}
559559
560- void crypto_ec_free_key (struct crypto_key * key )
560+ void crypto_ec_free_key (struct crypto_ec_key * key )
561561{
562562 mbedtls_pk_context * pkey = (mbedtls_pk_context * )key ;
563563 mbedtls_pk_free (pkey );
564564 os_free (key );
565565}
566566
567- struct crypto_ec_point * crypto_ec_key_get_public_key (struct crypto_key * key )
567+ struct crypto_ec_point * crypto_ec_key_get_public_key (struct crypto_ec_key * key )
568568{
569569 mbedtls_pk_context * pkey = (mbedtls_pk_context * )key ;
570570
571571 return (struct crypto_ec_point * )& mbedtls_pk_ec (* pkey )-> MBEDTLS_PRIVATE (Q );
572572}
573573
574- int crypto_ec_get_priv_key_der (struct crypto_key * key , unsigned char * * key_data , int * key_len )
574+ int crypto_ec_get_priv_key_der (struct crypto_ec_key * key , unsigned char * * key_data , int * key_len )
575575{
576576 mbedtls_pk_context * pkey = (mbedtls_pk_context * )key ;
577577 char * der_data = os_malloc (ECP_PRV_DER_MAX_BYTES );
@@ -599,7 +599,7 @@ int crypto_ec_get_priv_key_der(struct crypto_key *key, unsigned char **key_data,
599599 return 0 ;
600600}
601601
602- struct crypto_ec_group * crypto_ec_get_group_from_key (struct crypto_key * key )
602+ struct crypto_ec_group * crypto_ec_get_group_from_key (struct crypto_ec_key * key )
603603{
604604 mbedtls_pk_context * pkey = (mbedtls_pk_context * )key ;
605605
@@ -614,14 +614,14 @@ int crypto_ec_key_group(struct crypto_ec_key *key)
614614 return iana_group ;
615615}
616616
617- struct crypto_bignum * crypto_ec_key_get_private_key (struct crypto_key * key )
617+ struct crypto_bignum * crypto_ec_key_get_private_key (struct crypto_ec_key * key )
618618{
619619 mbedtls_pk_context * pkey = (mbedtls_pk_context * )key ;
620620
621621 return ((struct crypto_bignum * ) & (mbedtls_pk_ec (* pkey )-> MBEDTLS_PRIVATE (d )));
622622}
623623
624- int crypto_ec_get_publickey_buf (struct crypto_key * key , u8 * key_buf , int len )
624+ int crypto_ec_get_publickey_buf (struct crypto_ec_key * key , u8 * key_buf , int len )
625625{
626626 mbedtls_pk_context * pkey = (mbedtls_pk_context * )key ;
627627 unsigned char buf [MBEDTLS_MPI_MAX_SIZE + 10 ]; /* tag, length + MPI */
@@ -644,7 +644,7 @@ int crypto_ec_get_publickey_buf(struct crypto_key *key, u8 *key_buf, int len)
644644 return pk_len ;
645645}
646646
647- int crypto_write_pubkey_der (struct crypto_key * key , unsigned char * * key_buf )
647+ int crypto_write_pubkey_der (struct crypto_ec_key * key , unsigned char * * key_buf )
648648{
649649 unsigned char * buf = os_malloc (ECP_PUB_DER_MAX_BYTES );
650650
@@ -669,7 +669,7 @@ int crypto_write_pubkey_der(struct crypto_key *key, unsigned char **key_buf)
669669 return len ;
670670}
671671
672- struct crypto_key * crypto_ec_key_parse_priv (const u8 * privkey , size_t privkey_len )
672+ struct crypto_ec_key * crypto_ec_key_parse_priv (const u8 * privkey , size_t privkey_len )
673673{
674674 int ret ;
675675 mbedtls_pk_context * kctx = (mbedtls_pk_context * )crypto_alloc_key ();
@@ -685,7 +685,7 @@ struct crypto_key *crypto_ec_key_parse_priv(const u8 *privkey, size_t privkey_le
685685 goto fail ;
686686 }
687687
688- return (struct crypto_key * )kctx ;
688+ return (struct crypto_ec_key * )kctx ;
689689
690690fail :
691691 mbedtls_pk_free (kctx );
@@ -728,7 +728,7 @@ int crypto_ec_get_curve_id(const struct crypto_ec_group *group)
728728 return (crypto_ec_get_mbedtls_to_nist_group_id (grp -> id ));
729729}
730730
731- int crypto_ecdh (struct crypto_key * key_own , struct crypto_key * key_peer ,
731+ int crypto_ecdh (struct crypto_ec_key * key_own , struct crypto_ec_key * key_peer ,
732732 u8 * secret , size_t * secret_len )
733733{
734734 mbedtls_ecdh_context * ctx = NULL ;
@@ -795,7 +795,7 @@ int crypto_ecdh(struct crypto_key *key_own, struct crypto_key *key_peer,
795795}
796796
797797int crypto_ecdsa_get_sign (unsigned char * hash ,
798- const struct crypto_bignum * r , const struct crypto_bignum * s , struct crypto_key * csign , int hash_len )
798+ const struct crypto_bignum * r , const struct crypto_bignum * s , struct crypto_ec_key * csign , int hash_len )
799799{
800800 int ret = -1 ;
801801 mbedtls_pk_context * pkey = (mbedtls_pk_context * )csign ;
@@ -821,7 +821,7 @@ int crypto_ecdsa_get_sign(unsigned char *hash,
821821}
822822
823823int crypto_edcsa_sign_verify (const unsigned char * hash ,
824- const struct crypto_bignum * r , const struct crypto_bignum * s , struct crypto_key * csign , int hlen )
824+ const struct crypto_bignum * r , const struct crypto_bignum * s , struct crypto_ec_key * csign , int hlen )
825825{
826826 /* (mbedtls_ecdsa_context *) */
827827 mbedtls_ecp_keypair * ecp_kp = mbedtls_pk_ec (* (mbedtls_pk_context * )csign );
@@ -841,7 +841,7 @@ int crypto_edcsa_sign_verify(const unsigned char *hash,
841841 return ret ;
842842}
843843
844- void crypto_ec_key_debug_print (const char * title , struct crypto_key * key )
844+ void crypto_ec_key_debug_print (const char * title , struct crypto_ec_key * key )
845845{
846846#ifdef DEBUG_PRINT
847847 mbedtls_pk_context * pkey = (mbedtls_pk_context * )key ;
@@ -861,7 +861,7 @@ void crypto_ec_key_debug_print(const char *title, struct crypto_key *key)
861861#endif
862862}
863863
864- struct crypto_key * crypto_ec_parse_subpub_key (const unsigned char * p , size_t len )
864+ struct crypto_ec_key * crypto_ec_parse_subpub_key (const unsigned char * p , size_t len )
865865{
866866 int ret ;
867867 mbedtls_pk_context * pkey = (mbedtls_pk_context * )crypto_alloc_key ();
@@ -871,21 +871,21 @@ struct crypto_key *crypto_ec_parse_subpub_key(const unsigned char *p, size_t len
871871 }
872872 ret = mbedtls_pk_parse_subpubkey ((unsigned char * * )& p , p + len , pkey );
873873 if (ret == 0 ) {
874- return (struct crypto_key * )pkey ;
874+ return (struct crypto_ec_key * )pkey ;
875875 }
876876
877877 mbedtls_pk_free (pkey );
878878 os_free (pkey );
879879 return NULL ;
880880}
881881
882- int crypto_is_ec_key (struct crypto_key * key )
882+ int crypto_is_ec_key (struct crypto_ec_key * key )
883883{
884884 int ret = mbedtls_pk_can_do ((mbedtls_pk_context * )key , MBEDTLS_PK_ECKEY );
885885 return ret ;
886886}
887887
888- struct crypto_key * crypto_ec_key_gen (u16 ike_group )
888+ struct crypto_ec_key * crypto_ec_key_gen (u16 ike_group )
889889{
890890 mbedtls_pk_context * kctx = (mbedtls_pk_context * )crypto_alloc_key ();
891891
@@ -902,7 +902,7 @@ struct crypto_key * crypto_ec_key_gen(u16 ike_group)
902902 mbedtls_ecp_gen_key (MBEDTLS_ECP_DP_SECP256R1 , mbedtls_pk_ec (* kctx ), //get this from argument
903903 crypto_rng_wrapper , NULL );
904904
905- return (struct crypto_key * )kctx ;
905+ return (struct crypto_ec_key * )kctx ;
906906fail :
907907 mbedtls_pk_free (kctx );
908908 os_free (kctx );
@@ -1018,7 +1018,7 @@ int crypto_pk_write_formatted_pubkey_der(mbedtls_pk_context *key, unsigned char
10181018 return ((int ) len );
10191019}
10201020
1021- int crypto_ec_write_pub_key (struct crypto_key * key , unsigned char * * key_buf )
1021+ int crypto_ec_write_pub_key (struct crypto_ec_key * key , unsigned char * * key_buf )
10221022{
10231023 unsigned char output_buf [1600 ] = {0 };
10241024 int len = crypto_pk_write_formatted_pubkey_der ((mbedtls_pk_context * )key , output_buf , 1600 , 1 );
@@ -1140,7 +1140,7 @@ struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y,
11401140 struct crypto_bignum * bn_x = NULL ;
11411141 struct crypto_ec_point * ec_pt = NULL ;
11421142 uint8_t * px = NULL , * py = NULL , * buf = NULL ;
1143- struct crypto_key * pkey = NULL ;
1143+ struct crypto_ec_key * pkey = NULL ;
11441144 struct wpabuf * sh_secret = NULL ;
11451145 int secret_key = 0 ;
11461146
0 commit comments