Filtre de clé de compte (IV): il est généré en modifiant le premier octet de
de 0b00000100 à 0b00000110.
0x8C,0xA9,0x0C,0x08,0x1C
Champ "État de la connexion chiffrée" :
0xF4,0xBB,0x40,0x6F
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/13 (UTC).
[null,null,["Dernière mise à jour le 2025/08/13 (UTC)."],[[["\u003cp\u003eThis page provides test cases for providers to validate the cryptographic aspects of their Fast Pair implementation, including hashing, Bloom filter generation, and encryption.\u003c/p\u003e\n"],["\u003cp\u003eGoogle advises incorporating these tests early in the development process for smoother Fast Pair integration.\u003c/p\u003e\n"],["\u003cp\u003eTest cases encompass SHA-256 hashing, Bloom filter construction with and without battery data, AES encryption and decryption, ECDH key exchange, and AES key derivation from ECDH shared secret.\u003c/p\u003e\n"],["\u003cp\u003eExamples and expected outputs are included for each test case, covering scenarios like personalized name encoding/decoding and connection status field encryption.\u003c/p\u003e\n"],["\u003cp\u003eSuccessful completion of these tests ensures the provider's implementation aligns with Fast Pair's security requirements.\u003c/p\u003e\n"]]],[],null,["# Cryptographic Test Cases\n\nThis page describes tests a provider can write to verify the cryptographic\ncomponents of their provider implementation.\n\nGoogle recommends implementing these tests early to ease Fast Pair integration.\n\nTest Cases\n----------\n\nThese cases cover:\n\n- Hashing\n- The Bloom Filter\n- AES Encryption and Public Key Exchange\n- Message enciphering and deciphering\n\n### SHA-256 Hashing\n\nInput value: \n\n 0x11, 0x22, 0x33, 0x44, 0x55, 0x66\n\nHashed result: \n\n 0xBB, 0x00, 0x0D, 0xDD, 0x92, 0xA0, 0xA2, 0xA3, 0x46, 0xF0, 0xB5, 0x31,\n 0xF2, 0x78, 0xAF, 0x06, 0xE3, 0x70, 0xF8, 0x69, 0x32, 0xCC, 0xAF, 0xCC,\n 0xC8, 0x92, 0xD6, 0x8D, 0x35, 0x0F, 0x80, 0xF8\n\n### AES Encryption\n\nInput value: \n\n 0xF3, 0x0F, 0x4E, 0x78, 0x6C, 0x59, 0xA7, 0xBB, 0xF3, 0x87, 0x3B, 0x5A,\n 0x49, 0xBA, 0x97, 0xEA\n\nSecret key: \n\n 0xA0, 0xBA, 0xF0, 0xBB, 0x95, 0x1F, 0xF7, 0xB6, 0xCF, 0x5E, 0x3F, 0x45,\n 0x61, 0xC3, 0x32, 0x1D\n\nEncrypted output: \n\n 0xAC, 0x9A, 0x16, 0xF0, 0x95, 0x3A, 0x3F, 0x22, 0x3D, 0xD1, 0x0C, 0xF5,\n 0x36, 0xE0, 0x9E, 0x9C\n\n### ECDH Key Exchange\n\nBob's private key: \n\n 0x02, 0xB4, 0x37, 0xB0, 0xED, 0xD6, 0xBB, 0xD4, 0x29, 0x06, 0x4A, 0x4E,\n 0x52, 0x9F, 0xCB, 0xF1, 0xC4, 0x8D, 0x0D, 0x62, 0x49, 0x24, 0xD5, 0x92,\n 0x27, 0x4B, 0x7E, 0xD8, 0x11, 0x93, 0xD7, 0x63\n\nBob's public key: \n\n 0xF7, 0xD4, 0x96, 0xA6, 0x2E, 0xCA, 0x41, 0x63, 0x51, 0x54, 0x0A, 0xA3,\n 0x43, 0xBC, 0x69, 0x0A, 0x61, 0x09, 0xF5, 0x51, 0x50, 0x06, 0x66, 0xB8,\n 0x3B, 0x12, 0x51, 0xFB, 0x84, 0xFA, 0x28, 0x60, 0x79, 0x5E, 0xBD, 0x63,\n 0xD3, 0xB8, 0x83, 0x6F, 0x44, 0xA9, 0xA3, 0xE2, 0x8B, 0xB3, 0x40, 0x17,\n 0xE0, 0x15, 0xF5, 0x97, 0x93, 0x05, 0xD8, 0x49, 0xFD, 0xF8, 0xDE, 0x10,\n 0x12, 0x3B, 0x61, 0xD2\n\nAlice's private key: \n\n 0xD7, 0x5E, 0x54, 0xC7, 0x7D, 0x76, 0x24, 0x89, 0xE5, 0x7C, 0xFA, 0x92,\n 0x37, 0x43, 0xF1, 0x67, 0x77, 0xA4, 0x28, 0x3D, 0x99, 0x80, 0x0B, 0xAC,\n 0x55, 0x58, 0x48, 0x38, 0x93, 0xE5, 0xB0, 0x6D\n\nAlice's public key: \n\n 0x36, 0xAC, 0x68, 0x2C, 0x50, 0x82, 0x15, 0x66, 0x8F, 0xBE, 0xFE, 0x24,\n 0x7D, 0x01, 0xD5, 0xEB, 0x96, 0xE6, 0x31, 0x8E, 0x85, 0x5B, 0x2D, 0x64,\n 0xB5, 0x19, 0x5D, 0x38, 0xEE, 0x7E, 0x37, 0xBE, 0x18, 0x38, 0xC0, 0xB9,\n 0x48, 0xC3, 0xF7, 0x55, 0x20, 0xE0, 0x7E, 0x70, 0xF0, 0x72, 0x91, 0x41,\n 0x9A, 0xCE, 0x2D, 0x28, 0x14, 0x3C, 0x5A, 0xDB, 0x2D, 0xBD, 0x98, 0xEE,\n 0x3C, 0x8E, 0x4F, 0xBF\n\nGenerated shared key (either Alice's public + Bob's private or Bob's\npublic + Alice's private): \n\n 0x9D, 0xAD, 0xE4, 0xF8, 0x6A, 0xC3, 0x48, 0x8B, 0xBA, 0xC2, 0xAC, 0x34,\n 0xB5, 0xFE, 0x68, 0xA0, 0xEE, 0x5A, 0x67, 0x06, 0xF5, 0x43, 0xD9, 0x06,\n 0x1A, 0xD5, 0x78, 0x89, 0x49, 0x8A, 0xE6, 0xBA\n\n### AES Key from ECDH Shared Secret\n\nThis is step 1b (AES key generation) in the GATT [procedure](/nearby/fast-pair/specifications/service/gatt#procedure \"Procedure\").\n\nECDH shared key: \n\n 0x9D, 0xAD, 0xE4, 0xF8, 0x6A, 0xC3, 0x48, 0x8B, 0xBA, 0xC2, 0xAC, 0x34,\n 0xB5, 0xFE, 0x68, 0xA0, 0xEE, 0x5A, 0x67, 0x06, 0xF5, 0x43, 0xD9, 0x06,\n 0x1A, 0xD5, 0x78, 0x89, 0x49, 0x8A, 0xE6, 0xBA\n\nGenerated AES key: \n\n 0xB0, 0x7F, 0x1F, 0x17, 0xC2, 0x36, 0xCB, 0xD3, 0x35, 0x23, 0xC5, 0x15,\n 0xF3, 0x50, 0xAE, 0x57\n\n### Bloom Filter\n\nRandom salt: \n\n 0xC7C8\n\nFirst account key added to the filter (combine with the above random salt): \n\n 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0xAA, 0xBB,\n 0xCC, 0xDD, 0xEE, 0xFF\n\nResulting bloom filter: \n\n 0x02, 0x0C, 0x80, 0x2A\n\nBattery data (if it is contained in the advertisement): \n\n 0b00110011, // length = 3, show UI indication.\n 0b01000000, // left bud: not charging, battery level = 64.\n 0b01000000, // right bud: not charging, battery level = 64.\n 0b01000000 // case: not charging, battery level = 64.\n\nResulting bloom filter with battery data: \n\n 0x01, 0x01, 0x46, 0x0A\n\nSecond account key added to the filter (combine with the above random salt): \n\n 0x11, 0x11, 0x22, 0x22, 0x33, 0x33, 0x44, 0x44, 0x55, 0x55, 0x66, 0x66,\n 0x77, 0x77, 0x88, 0x88\n\nResulting bloom filter from both added account keys: \n\n 0x84, 0x4A, 0x62, 0x20, 0x8B\n\nBattery data (if it is contained in the advertisement): \n\n 0b00110011, // length = 3, show UI indication.\n 0b01000000, // left bud: not charging, battery level = 64.\n 0b01000000, // right bud: not charging, battery level = 64.\n 0b01000000 // case: not charging, battery level = 64.\n\nResulting bloom filter from both added account keys with battery data: \n\n 0x46, 0x15, 0x24, 0xD0, 0x08\n\n### AES-CTR Encryption\n\nInput data: \"Someone's Google Headphone\" with utf-8 encoding \n\n 0x53, 0x6F, 0x6D, 0x65, 0x6F, 0x6E, 0x65, 0x27, 0x73, 0x20, 0x47, 0x6F,\n 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x48, 0x65, 0x61, 0x64, 0x70, 0x68, 0x6F,\n 0x6E, 0x65\n\nSecret key: \n\n 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67,\n 0x89, 0xAB, 0xCD, 0xEF\n\nNonce: \n\n 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07\n\nExpected encryption result: \n\n 0xEE, 0x4A, 0x24, 0x83, 0x73, 0x80, 0x52, 0xE4, 0x4E, 0x9B, 0x2A, 0x14,\n 0x5E, 0x5D, 0xDF, 0xAA, 0x44, 0xB9, 0xE5, 0x53, 0x6A, 0xF4, 0x38, 0xE1,\n 0xE5, 0xC6\n\n### HMAC-SHA256\n\nInput data: \n\n 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0xEE, 0x4A, 0x24, 0x83,\n 0x73, 0x80, 0x52, 0xE4, 0x4E, 0x9B, 0x2A, 0x14, 0x5E, 0x5D, 0xDF, 0xAA,\n 0x44, 0xB9, 0xE5, 0x53, 0x6A, 0xF4, 0x38, 0xE1, 0xE5, 0xC6\n\nSecret key: \n\n 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67,\n 0x89, 0xAB, 0xCD, 0xEF\n\nExpected HMAC-SHA256 result: \n\n 0x55, 0xEC, 0x5E, 0x60, 0x55, 0xAF, 0x6E, 0x92, 0x61, 0x8B, 0x7D, 0x87,\n 0x10, 0xD4, 0x41, 0x37, 0x09, 0xAB, 0x5D, 0xA2, 0x7C, 0xA2, 0x6A, 0x66,\n 0xF5, 0x2E, 0x5A, 0xD4, 0xE8, 0x20, 0x90, 0x52\n\n### Encode personalized name to additional data packet\n\nInput data: \"Someone's Google Headphone\" with utf-8 encoding \n\n 0x53, 0x6F, 0x6D, 0x65, 0x6F, 0x6E, 0x65, 0x27, 0x73, 0x20, 0x47, 0x6F,\n 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x48, 0x65, 0x61, 0x64, 0x70, 0x68, 0x6F,\n 0x6E, 0x65\n\nSecret key: \n\n 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67,\n 0x89, 0xAB, 0xCD, 0xEF\n\nNonce: \n\n 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07\n\nExpected additional data packet: \n\n 0x55, 0xEC, 0x5E, 0x60, 0x55, 0xAF, 0x6E, 0x92, 0x00, 0x01, 0x02, 0x03,\n 0x04, 0x05, 0x06, 0x07, 0xEE, 0x4A, 0x24, 0x83, 0x73, 0x80, 0x52, 0xE4,\n 0x4E, 0x9B, 0x2A, 0x14, 0x5E, 0x5D, 0xDF, 0xAA, 0x44, 0xB9, 0xE5, 0x53,\n 0x6A, 0xF4, 0x38, 0xE1, 0xE5, 0xC6\n\n### Decode additional data packet to get personalized name\n\nInput data: \n\n 0x55, 0xEC, 0x5E, 0x60, 0x55, 0xAF, 0x6E, 0x92, 0x00, 0x01, 0x02, 0x03,\n 0x04, 0x05, 0x06, 0x07, 0xEE, 0x4A, 0x24, 0x83, 0x73, 0x80, 0x52, 0xE4,\n 0x4E, 0x9B, 0x2A, 0x14, 0x5E, 0x5D, 0xDF, 0xAA, 0x44, 0xB9, 0xE5, 0x53,\n 0x6A, 0xF4, 0x38, 0xE1, 0xE5, 0xC6\n\nSecret key: \n\n 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67,\n 0x89, 0xAB, 0xCD, 0xEF\n\nExpected name: \"Someone's Google Headphone\" with utf-8 encoding \n\n 0x53, 0x6F, 0x6D, 0x65, 0x6F, 0x6E, 0x65, 0x27, 0x73, 0x20, 0x47, 0x6F,\n 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x48, 0x65, 0x61, 0x64, 0x70, 0x68, 0x6F,\n 0x6E, 0x65\n\n### Encrypted connection status field\n\nField length and type: \n\n 0b001100101 (length = 3, type = connection status field)\n\nConnection state: \n\n 0b10000101:\n\n * on head detection = 1\n * connection availability = 0\n * focus mode = 0\n * auto-reconnected = 0\n * connection state = 0x5 (A2DP with AVRCP)\n\nCustom data: \n\n 0x38\n\nConnected devices bitmap: \n\n 0b00001001\n\nConnection status field raw data (combine above 4 bytes): \n\n 0x35853809\n\nIn use account key (this is the Key): \n\n 0x04, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0xAA, 0xBB,\n 0xCC, 0xDD, 0xEE, 0xFF\n\nNon-in use account key: \n\n 0x04, 0x11, 0x22, 0x22, 0x33, 0x33, 0x44, 0x44, 0x55, 0x55, 0x66, 0x66,\n 0x77, 0x77, 0x88, 0x88\n\nRandom salt: \n\n 0xC7C8\n\nAccount key filter (this is IV): this is generated by changing the first byte of\nin use account key from 0b00000100 to 0b00000110. \n\n 0x8C, 0xA9, 0x0C, 0x08, 0x1C\n\nEncrypted connection status field: \n\n 0xF4, 0xBB, 0x40, 0x6F\n\n| **Note:** this is encrypted by the original account key, in other words, the first byte of the key is 0x04 not 0x06"]]