File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -285,11 +285,14 @@ def pubkey_parms_from_tpm2b_public(
285285 (_ , sym_parms ) = _extract_tpm2b (public [8 :])
286286 # Ignore the non-asym-alg parameters
287287 (sym_alg ,) = struct .unpack (">H" , sym_parms [0 :2 ])
288+ (scheme_alg ,) = struct .unpack (">H" , sym_parms [2 :4 ])
288289 # Ignore the sym_mode and keybits (4 bytes), possibly symmetric (2) and sign
289290 # scheme (2)
290- to_skip = 4 + 2 # sym_mode, keybits and sign scheme
291+ to_skip = 4 # sym_mode, keybits
291292 if sym_alg != TPM2_ALG_NULL :
292293 to_skip = to_skip + 2
294+ if scheme_alg != TPM2_ALG_NULL :
295+ to_skip = to_skip + 2
293296 asym_parms = sym_parms [to_skip :]
294297
295298 # Handle fields
Original file line number Diff line number Diff line change @@ -262,6 +262,21 @@ def test_pubkey_from_tpm2b_public_ec(self) -> None:
262262 self .assertEqual (new_ec_pubkey_n .x , correct_ec_pubkey_n .x )
263263 self .assertEqual (new_ec_pubkey_n .y , correct_ec_pubkey_n .y )
264264
265+ def test_pubkey_from_tpm2b_public_rsa_2 (self ) -> None :
266+ # This key has Null set for the RSA scheme algorithm
267+ test_pubkey_bytes = base64 .b64decode (
268+ "ATYAAQALAAQA8gAgrWs6IoT9aYoHEL9cwbm98V4lMuP2AfpLk6ao+o3leeoAEAAQCA"
269+ "AAAAAAAQCUcktf2f6TOoVE94USfvExBIRumw5AOD2ahxDLXvYgTZoCEfIo4B1y/9o5"
270+ "4aKs8eclm1ez1huCcSklaI07MQnSFv+YgmMsmGd9CQNe0b5uL9nGXDDHVEUeRERj/i"
271+ "ZU82KEiXMYGs/8RfocrdFihsSKD/Xmgary+HU1HwkxWWPHYtFRLTlQgrqKJ1CckUaf"
272+ "BHKyWvjjRLEhZC0YOZWAtbGN3bOJZ3FzBV21lx7e7RsBxBwUhQrRPbWh6UTb/lKBn8"
273+ "pQgRLqb/wB5m99O7HzpKIy/trAQDnalPg2izgt7MByesMwTpJ0KGlwo69xus/UaE9a"
274+ "apMZTnYR6W2mM2H6vrKl"
275+ )
276+ new_rsa_pubkey , name_alg = pubkey_parms_from_tpm2b_public (test_pubkey_bytes )
277+ self .assertIsInstance (new_rsa_pubkey , rsa .RSAPublicKey )
278+ self .assertEqual (name_alg , TPM_ALG_SHA256 )
279+
265280 def test_pubkey_from_tpm2b_public_ec_without_encryption (self ) -> None :
266281 new_ec_pubkey = pubkey_from_tpm2b_public (
267282 bytes .fromhex (
You can’t perform that action at this time.
0 commit comments