Skip to content

Commit f53c4db

Browse files
Thalleykartben
authored andcommitted
Bluetooth: CSIP: Update documentation for CSIP crypto functions
The encryption functions should document the expect byte order of inputs and the byte order of the outputs. The sef and sdf functions were also using an older, and incorrect, description of the input, as it only takes the LTK as per CSIP 1.0.0 Signed-off-by: Emil Gydesen <[email protected]>
1 parent f3d513d commit f53c4db

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

subsys/bluetooth/audio/csip_crypto.h

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
* used in RSIs - Used by the Coordinated Set Identification service and
2323
* profile.
2424
*
25-
* @param sirk 16 byte LS byte first SIRK
26-
* @param r 3 byte LS byte first random value
27-
* @param out 3 byte LS byte first output buffer
25+
* @param sirk 16-byte SIRK in little-endian byte order.
26+
* @param r 3-byte random value in little-endian byte order.
27+
* @param out 3-byte output buffer in little-endian byte order.
28+
*
2829
* @return int 0 on success, any other value indicates a failure.
2930
*/
3031
int bt_csip_sih(const uint8_t sirk[BT_CSIP_SIRK_SIZE], uint8_t r[BT_CSIP_CRYPTO_PRAND_SIZE],
@@ -37,20 +38,18 @@ int bt_csip_sih(const uint8_t sirk[BT_CSIP_SIRK_SIZE], uint8_t r[BT_CSIP_CRYPTO_
3738
* with a key K. The value of K depends on the transport on which the pairing
3839
* between the client and the server was performed.
3940
*
40-
* If the pairing was performed on BR/EDR, K is equal to the Link Key shared by
41-
* the server and the client.
41+
* If the pairing was performed on Basic Rate/Enhanced Data Rate (BR/EDR), K is equal to the
42+
* Link Key shared by the server and the client.
4243
* K = Link Key.
4344
*
44-
* If the pairing was performed on LE, the 64 LSBs of K correspond to the 64
45-
* LSBs of the IRK that the server sent to the client during the Phase 3
46-
* (Transport Specific Key Distribution) of the pairing procedure (see Volume 3,
47-
* Part H, Section 2.1 in [2]), and the 64 MSBs of K correspond to the 64 MSBs
48-
* of the LTK shared by the server and client. That is,
49-
* K = LTK_64-127 || IRK_0-63
45+
* If the pairing was performed on Bluetooth Low Energy (LE), K is equal to the LTK shared by the
46+
* server and client. That is,
47+
* K = LTK
48+
*
49+
* @param k 16-byte key in little-endian byte order.
50+
* @param sirk 16-byte unencrypted SIRK key in little-endian byte order.
51+
* @param out_sirk 16-byte encrypted SIRK key in little-endian byte order.
5052
*
51-
* @param k 16-byte key.
52-
* @param sirk The unencrypted SIRK.
53-
* @param out_sirk The encrypted SIRK.
5453
* @return int 0 on success, any other value indicates a failure.
5554
*/
5655
int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], const uint8_t sirk[BT_CSIP_SIRK_SIZE],
@@ -63,20 +62,18 @@ int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], const uint8_t sirk[BT_
6362
* with a key K. The value of K depends on the transport on which the pairing
6463
* between the client and the server was performed.
6564
*
66-
* If the pairing was performed on BR/EDR, K is equal to the Link Key shared by
67-
* the server and the client.
65+
* If the pairing was performed on Basic Rate/Enhanced Data Rate (BR/EDR), K is equal to the
66+
* Link Key shared by the server and the client.
6867
* K = Link Key.
6968
*
70-
* If the pairing was performed on LE, the 64 LSBs of K correspond to the 64
71-
* LSBs of the IRK that the server sent to the client during the Phase 3
72-
* (Transport Specific Key Distribution) of the pairing procedure (see Volume 3,
73-
* Part H, Section 2.1 in [2]), and the 64 MSBs of K correspond to the 64 MSBs
74-
* of the LTK shared by the server and client. That is,
75-
* K = LTK_64-127 || IRK_0-63
69+
* If the pairing was performed on Bluetooth Low Energy (LE), K is equal to the LTK shared by the
70+
* server and client. That is,
71+
* K = LTK
72+
*
73+
* @param k 16-byte key in little-endian byte order.
74+
* @param sirk 16-byte encrypted SIRK in little-endian byte order.
75+
* @param out_sirk 16-byte decrypted SIRK in little-endian byte order.
7676
*
77-
* @param k 16-byte key.
78-
* @param sirk The encrypted SIRK.
79-
* @param out_sirk The decrypted SIRK.
8077
* @return int 0 on success, any other value indicates a failure.
8178
*/
8279
int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], const uint8_t enc_sirk[BT_CSIP_SIRK_SIZE],

subsys/bluetooth/audio/csip_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
struct bt_csip_sirk {
2323
uint8_t type;
24+
/* SIRK stored in little endian byte order. */
2425
uint8_t value[BT_CSIP_SIRK_SIZE];
2526
} __packed;
2627

0 commit comments

Comments
 (0)