// F2345 takes key K and random challenge RAND, and returns response RES,
// confidentiality key CK, integrity key IK and anonymity key AK.
F2345 takes key K and random challenge RAND, and returns response RES,
confidentiality key CK, integrity key IK and anonymity key AK.
// F2345 takes key K and random challenge RAND and returns response RES // confidentiality key CK integrity key IK and anonymity key AK .
func (m *Milenage) F2345() (res, ck, ik, ak []byte, err error) {
	if err := m.validateLength(); err != nil {
		return nil, nil, nil, nil, err
	}
	if m.OPc == nil {
		if err := m.computeOPc(); err != nil {
			return nil, nil, nil, nil, err
		}
	}
	rijndaelInput := make([]byte, 16)
	for i := 0; i < 16; i++ {
		rijndaelInput[i] = m.RAND[i] ^ m.OPc[i]
	}
	temp, err := encrypt(m.K, rijndaelInput)
	if err != nil {
		return
	}
	for i := 0; i < 16; i++ {
		rijndaelInput[i] = temp[i] ^ m.OPc[i]
	}
	rijndaelInput[15] ^= 1
	out, err := encrypt(m.K, rijndaelInput)
	if err != nil {
		return
	}
	tmp := xor(out, m.OPc)
	res = tmp[8:]
	ak = tmp[:6]
	for i := 0; i < 16; i++ {
		rijndaelInput[(i+12)%16] = temp[i] ^ m.OPc[i]
	}
	rijndaelInput[15] ^= 2
	out, err = encrypt(m.K, rijndaelInput)
	if err != nil {
		return
	}
	ck = xor(out, m.OPc)
	for i := 0; i < 16; i++ {
		rijndaelInput[(i+8)%16] = temp[i] ^ m.OPc[i]
	}
	rijndaelInput[15] ^= 4
	out, err = encrypt(m.K, rijndaelInput)
	if err != nil {
		return
	}
	ik = xor(out, m.OPc)
	m.RES = res
	m.CK = ck
	m.IK = ik
	m.AK = ak
	return res, ck, ik, ak, nil
}
func ( m * Milenage ) F2345 ( ) ( res , ck , ik , ak [ ] byte , err error ) { if err := m . validateLength ( ) ; err != nil { return nil , nil , nil , nil , err } if m . OPc == nil { if err := m . computeOPc ( ) ; err != nil { return nil , nil , nil , nil , err } } rijndaelInput := make ( [ ] byte , 16 ) for i := 0 ; i < 16 ; i ++ { rijndaelInput [ i ] = m . RAND [ i ] ^ m . OPc [ i ] } temp , err := encrypt ( m . K , rijndaelInput ) if err != nil { return } for i := 0 ; i < 16 ; i ++ { rijndaelInput [ i ] = temp [ i ] ^ m . OPc [ i ] } rijndaelInput [ 15 ] ^= 1 out , err := encrypt ( m . K , rijndaelInput ) if err != nil { return } tmp := xor ( out , m . OPc ) res = tmp [ 8 : ] ak = tmp [ : 6 ] for i := 0 ; i < 16 ; i ++ { rijndaelInput [ ( i + 12 ) % 16 ] = temp [ i ] ^ m . OPc [ i ] } rijndaelInput [ 15 ] ^= 2 out , err = encrypt ( m . K , rijndaelInput ) if err != nil { return } ck = xor ( out , m . OPc ) for i := 0 ; i < 16 ; i ++ { rijndaelInput [ ( i + 8 ) % 16 ] = temp [ i ] ^ m . OPc [ i ] } rijndaelInput [ 15 ] ^= 4 out , err = encrypt ( m . K , rijndaelInput ) if err != nil { return } ik = xor ( out , m . OPc ) m . RES = res m . CK = ck m . IK = ik m . AK = ak return res , ck , ik , ak , nil }
F2345 takes key K and random challenge RAND, and returns response RES,
confidentiality key CK, integrity key IK and anonymity key AK.
F2345 takes key K and random challenge RAND and returns response RES confidentiality key CK integrity key IK and anonymity key AK .
// To obtain output block OUT2: XOR OPc and TEMP, rotate by r2=0, and XOR on the // constant c2 (which is all zeroes except that the last bit is 1). // To obtain output block OUT3: XOR OPc and TEMP, rotate by r3=32, and XOR on the // constant c3 (which is all zeroes except that the next to last bit is 1). // To obtain output block OUT4: XOR OPc and TEMP, rotate by r4=64, and XOR on the // constant c4 (which is all zeroes except that the 2nd from last bit is 1).