use bit shifts
This commit is contained in:
parent
4743fd2326
commit
72063049a7
13
fido2/ctap.c
13
fido2/ctap.c
@ -597,18 +597,21 @@ static uint32_t ctap_assertion_led_colour(uint8_t * seed, uint32_t slen)
|
||||
crypto_sha256_hmac_final(seed, slen, hmac);
|
||||
uint32_t colour = 0;
|
||||
uint32_t backlist[] = {0x00FF00};
|
||||
uint32_t dist = 0;
|
||||
uint32_t min_dist = 40*40*3;
|
||||
int dist = 0;
|
||||
int min_dist = 50*50*3;
|
||||
for(int i=0; i<32-3 && (dist < min_dist || i == 0);i++) {
|
||||
uint8_t* rgb = &hmac[i];
|
||||
colour = ((uint32_t*) rgb)[0] & 0x0000ffffff;
|
||||
uint32_t r, g, b = 0;
|
||||
int r, g, b = 0;
|
||||
r = colour & 0x0000ff0000 >> 16;
|
||||
g = colour & 0x000000ff00 >> 8;
|
||||
b = colour & 0x00000000ff;
|
||||
for(int j=0; j < 1 && dist < min_dist; j++) {
|
||||
uint8_t* b_rgb = &((uint8_t*) &backlist[j])[1];
|
||||
dist = ((int) r - b_rgb[2])*(r - b_rgb[2]) + ((int)g - b_rgb[1])*((int)g - b_rgb[1]) + ((int)b - b_rgb[0])*((int)b - b_rgb[0]);
|
||||
int br, bg, bb = 0;
|
||||
br = backlist[j] & 0x0000ff0000 >> 16;
|
||||
bg = backlist[j] & 0x000000ff00 >> 8;
|
||||
bb = backlist[j] & 0x00000000ff;
|
||||
dist = ((int) r - br)*(r - br) + ((int)g - bg)*((int)g - bg) + ((int)b - bb)*((int)b - bb);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user