fido-alliance / iot-fdo-conformance-tools

FIDO Alliances Reference FDO Implementation and Conformance Testing
https://fidoalliance.org/intro-to-fido-device-onboard/
Other
5 stars 2 forks source link

[BUG] Difference in key generated by KDF for encryption and decryption #46

Closed Sai-Anudeep47 closed 1 year ago

Sai-Anudeep47 commented 1 year ago

To simplify issue resolution process, please provide network logs, and or test voucher. KDF_loop

What part of the spec are you testing?

What protocol are having issue with?

Issue description

rftemple commented 1 year ago

The L2 value is also currently written as Little Endian and the bytes need to be reversed for Big Endian. This is in addition to the loop start with 1 vs 0.

func Sp800108CounterKDF(sizeBytes int, hmacAlg HashType, key []byte, contextRand []byte) ([]byte, error) { //this should be 1 vs 0 per spec for i := 1; i < n; i += 1 { mac.Write([]byte{byte(i)}) mac.Write([]byte(CONST_KDF_LABEL)) mac.Write([]byte{byte(0x00)}) // Separator mac.Write([]byte(CONST_KDF_CONTEXT)) mac.Write(contextRand)

    Lbigend := []byte{byte((l & 0xff)), byte((l >> 8) & 0xff)}

// this should be reversed for big endian Lbigend := []byte{ byte((l >> 8) & 0xff),byte((l & 0xff))} mac.Write(Lbigend)

    result = append(result, mac.Sum(nil)...)
    mac.Reset()
}

return result[0:sizeBytes], nil

}

256 in Big endian to array is [1,0] 256 in Little endian to array is [0,1] (current output)

yackermann commented 1 year ago

yes, you are correct @rftemple @Sai-Anudeep47!