Skip to content

Commit

Permalink
[enhancement] Small fix in the API to expose both receive and send ma…
Browse files Browse the repository at this point in the history
…x values.
  • Loading branch information
rben-dev committed May 16, 2019
1 parent 82ce39a commit d3d45fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/wookey/common/SecureChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,14 @@ private void add_iv(short num){
increment_iv();
}
}
public short get_max_sc_apdu_len(){
public short get_max_sc_apdu_recv_len(){
/* Maximum receive size is Lc max = 255 minus HMAC size */
return (short)(255 - hmac_ctx.hmac_len());
}
public short get_max_sc_apdu_send_len(){
/* Maximum send size is Le max = 256 minux HMAC size */
return (short)(256 - hmac_ctx.hmac_len());
}
public short receive_encrypted_apdu(APDU apdu, byte[] outdata){
short receivedLen = apdu.setIncomingAndReceive();
byte buffer[] = apdu.getBuffer();
Expand Down
4 changes: 2 additions & 2 deletions src/wookey/common/WooKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ private void get_random(APDU apdu, byte ins){
return;
}
else{
/* This instruction expects a byte containing the size of random data to provide (maximum 255 bytes minus a HMAC size) */
/* This instruction expects a byte containing the size of random data to provide (maximum 256 bytes minus a HMAC size) */
short rand_len = (short)(data[0] & 0x00ff);
if(rand_len > schannel.get_max_sc_apdu_len()){
if(rand_len > schannel.get_max_sc_apdu_send_len()){
schannel.send_encrypted_apdu(apdu, null, (short) 0, (short) 0, ins, (byte) 0x03);
return;
}
Expand Down

0 comments on commit d3d45fe

Please sign in to comment.