- Notifications
You must be signed in to change notification settings - Fork2
atesgoral/milenage
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
3GPP authentication and key generation functions.
JavaScript implementation based on the C reference implementation from Annex 3 ofETSI TS 135 206 V14.0.0 (2017-04).
Install from npm:
npm install --save milenage
Then:
const Milenage = require('milenage');const milenage = new Milenage({ op, key }); // Or: new Milenage({ op_c, key });const { mac_a } = milenage.f1(rand, sqn, amf);const { res, ck, ik, ak } = milenage.f2345(rand);const { mac_s } = milenage.f1star(rand, sqn, amf);const { ak_s } = milenage.f5star(rand);
All functions also return the OPc value as theop_c
property:
const { op_c } = milenage.f1(rand, sqn, amf);
You can also just get the OPc value by:
const op_c = milenage.op_c();
All inputs and outputs areUint8Array
instances.
Inputs:
op
is theOP: a 128-bit Operator Variant Algorithm Configuration Field that is a component of the functions f1,f1*, f2, f3, f4, f5 and f5*.op_c
is theOPc: The intermediate value derived from a combination of OP and K for use in functions. If OPc is passed in, OP is ignored and functions start off their computations based on the OPc value you have provided.key
is theK: a 128-bit subscriber key that is an input to the functions f1, f1*, f2, f3, f4, f5 and f5*.rand
is theRAND: a 128-bit random challenge that is an input to the functions f1, f1*, f2, f3, f4, f5 and f5*.sqn
is theSQN: a 48-bit sequence number that is an input to either of the functions f1 and f1*. (For f1* this input is more precisely called SQNMS.)amf
is theAMF: a 16-bit authentication management field that is an input to the functions f1 and f1*.
Outputs:
op_c
is theOPc: The value derived from OP and K. This will be the same value as the optional opc input parameter.mac_a
is theMAC-A: a 64-bit network authentication code that is the output of the function f1.res
is theRES: a 64-bit signed response that is the output of the function f2.ck
is theCK: a 128-bit confidentiality key that is the output of the function f3.ik
is theIK: a 128-bit integrity key that is the output of the function f4.ak
is theAK: a 48-bit anonymity key that is the output of the function f5.mac_s
is theMAC-S: a 64-bit resynchronisation authentication code that is the output of the function f1*.ak_s
is theAK-S: a 48-bit anonymity key that is the output of the function f5*.
Illustrative example:
const Milenage = require('milenage');const op = new Uint8Array([ 0x63, 0xbf, 0xa5, 0x0e, 0xe6, 0x52, 0x33, 0x65, 0xff, 0x14, 0xc1, 0xf4, 0x5f, 0x88, 0x73, 0x7d ]);const key = new Uint8Array([ 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f, 0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc ]);const rand = new Uint8Array([ 0xdc, 0xef, 0xf0, 0x15, 0xac, 0xa4, 0x44, 0x3b, 0xda, 0xdb, 0x05, 0x00, 0x85, 0x01, 0x08, 0xa7 ]);const sqn = new Uint8Array([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x95 ]);const amf = new Uint8Array([ 0x80, 0x00 ]);const milenage = new Milenage({ op, key });const { mac_a } = milenage.f1(rand, sqn, amf);const { res, ck, ik, ak } = milenage.f2345(rand);const { mac_s } = milenage.f1star(rand, sqn, amf);const { ak_s } = milenage.f5star(rand);function toHex(typedArray) { return Buffer.from(typedArray).toString('hex');}console.log('MACa:', toHex(mac_a));console.log('RES:', toHex(res));console.log('CK:', toHex(ck));console.log('IK:', toHex(ik));console.log('AK:', toHex(ak));console.log('MACs:', toHex(mac_s));console.log('AKs:', toHex(ak_s));
About
MILENAGE algorithm for Node.js
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.