@@ -54,9 +54,6 @@ public class U2FServerReferenceImpl implements U2FServer {
5454
5555 // Object Identifier for the attestation certificate transport extension fidoU2FTransports
5656 private static final String TRANSPORT_EXTENSION_OID = "1.3.6.1.4.1.45724.2.1.1" ;
57- // The number of bits in a byte. It is used to know at which index in a BitSet to look for
58- // specific transport values
59- private static final int BITS_IN_A_BYTE = 8 ;
6057
6158 private static final String TYPE_PARAM = "typ" ;
6259 private static final String CHALLENGE_PARAM = "challenge" ;
@@ -355,33 +352,17 @@ public static List<Transports> parseTransportsExtension(X509Certificate cert)
355352 DERBitString bitString = (DERBitString ) asn1Object ;
356353
357354 byte [] values = bitString .getBytes ();
358- int nrBytesUsed = values .length ;
359- // Check if more than one byte was used to store the transport values
360- // If so, we need to reverse the byte order before feeding them to a BitSet object
361- // This is because when reading from a byte array, a BitSet starts reading from the end
362- if (nrBytesUsed > 1 ) {
363- values = reverseOrderOfBytes (values );
364- }
365355 BitSet bitSet = BitSet .valueOf (values );
366356
367- // Parse the actual transport values
368- int nrBitsUsed = nrBytesUsed * BITS_IN_A_BYTE ;
369357 // We might have more defined transports than used by the extension
370- for (int i = 0 ; i < Transports . values (). length && i < nrBitsUsed ; i ++) {
371- if (bitSet .get (nrBitsUsed - i - 1 )) {
358+ for (int i = 0 ; i < 8 ; i ++) {
359+ if (bitSet .get (8 - i - 1 )) {
372360 transportsList .add (Transports .values ()[i ]);
373361 }
374362 }
375363 return transportsList ;
376364 }
377365
378- private static byte [] reverseOrderOfBytes (byte [] input ) {
379- byte [] output = new byte [input .length ];
380- for (int i = 0 ; i < input .length ; i ++) {
381- output [i ] = input [input .length - i - 1 ];
382- }
383- return output ;
384- }
385366 private void verifyBrowserData (JsonElement browserDataAsElement ,
386367 String messageType , EnrollSessionData sessionData ) throws U2FException {
387368
0 commit comments