Hi,
☎ wrote:
I've got rid of unnecessary cycle and to made
difference between v2 and
v3 more visible: v2 is basically just v3 with last bits of Kc zeroed.
Also - small readability improvements.
More on this below.
Also I've added test suite with test vectors from
original python implementation.
Cool!
+++ b/include/osmocom/gsm/comp128v23.h
@@ -13,11 +13,11 @@
* Performs the COMP128 version 2 and 3 algorithm (used as A3/A8)
* ki : uint8_t [16]
* srand : uint8_t [16]
- * version : uint8_t (2 or 3)
* sres : uint8_t [4]
* kc : uint8_t [8]
* returns 1 if not version 2 or 3 specified
*/
-int comp128v23(const uint8_t *ki, const uint8_t *rand, uint8_t version, uint8_t *sres,
uint8_t *kc);
Since this is a public API I don't know if the old function can be removed.
+int comp128v3(const uint8_t *ki, const uint8_t *rand,
uint8_t *sres, uint8_t *kc);
+int comp128v3(const uint8_t *ki, const uint8_t *rand, uint8_t *sres, uint8_t *kc);
Copypaste error here. I think it's nice to add two new functions, but
probably the old one needs to stay there.
+++ b/src/gsm/auth_comp128v23.c
@@ -31,7 +31,7 @@ static int c128v2_gen_vec(struct osmo_auth_vector *vec,
struct osmo_sub_auth_data *aud,
const uint8_t *_rand)
{
- comp128v23(aud->u.gsm.ki, _rand, 2, vec->sres, vec->kc);
+ comp128v2(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
vec->auth_types = OSMO_AUTH_TYPE_GSM;
return 0;
I like this change, thanks to the two new functions.
//Peter