Skip to content

Commit

Permalink
[coco][fuji] base64_encode_length
Browse files Browse the repository at this point in the history
  • Loading branch information
tschak909 committed May 1, 2024
1 parent 33f8e43 commit 1a4ba19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/device/drivewire/fuji.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,26 @@ void drivewireFuji::base64_encode_compute()

base64.base64_buffer.clear();
base64.base64_buffer = std::string(p.get(), out_len);


errorCode = 1;
}

void drivewireFuji::base64_encode_length()
{
size_t l = base64.base64_buffer.length();
uint8_t o[4] =
{
(uint8_t)(l >> 24),
(uint8_t)(l >> 16),
(uint8_t)(l >> 8),
(uint8_t)(l)
};

response.clear();
response.shrink_to_fit();

response = std::string((const char *)&o, 4);

errorCode = 1;
}

Expand Down Expand Up @@ -1492,8 +1511,10 @@ void drivewireFuji::process()
base64_encode_input();
break;
case FUJICMD_BASE64_ENCODE_COMPUTE:
base64_encode_compute();
break;
case FUJICMD_BASE64_ENCODE_LENGTH:
base64_encode_length();
break;
case FUJICMD_BASE64_ENCODE_OUTPUT:
break;
Expand Down
1 change: 1 addition & 0 deletions lib/device/drivewire/fuji.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class drivewireFuji : public virtualDevice
void random(); // 0xD3
void base64_encode_input(); // 0xD0
void base64_encode_compute(); // 0xCF
void base64_encode_length(); // 0xCE
void send_error();
void send_response(); // 0x01
void ready(); // 0x00
Expand Down

0 comments on commit 1a4ba19

Please sign in to comment.