8000 close makinako:master#72: Add rmac/renc support in outgoing chainBuffer by easydaniel · Pull Request #73 · makinako/OpenFIPS201 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

close makinako:master#72: Add rmac/renc support in outgoing chainBuffer #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/com/makina/security/openfips201/ChainBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import javacard.framework.ISOException;
import javacard.framework.JCSystem;
import javacard.framework.Util;
import org.globalplatform.GPSystem;
import org.globalplatform.SecureChannel;

/**
* ChainBuffer supports reading and writing of buffers larger than a single APDU frame. It takes
Expand Down Expand Up @@ -160,6 +162,19 @@ void setOutgoing(byte[] buffer, short offset, short length, boolean clearOnCompl

reset();

// Wrap response if messaging in secure channel: either R_MAC or R_ENCRYPTION is set
SecureChannel sc = GPSystem.getSecureChannel();
byte mask = SecureChannel.R_MAC | SecureChannel.R_ENCRYPTION;
if ((sc.getSecurityLevel() & SecureChannel.AUTHENTICATED) != 0
&& (sc.getSecurityLevel() & mask) != 0) {
// Add status word to build response mac
// TODO: check boundaries of buffer & length
buffer[length] = (byte) 0x90;
buffer[(short) (length + 1)] = (byte) 0x00;
length += 2;
length = sc.wrap(buffer, (byte) 0x00, length);
}

dataPtr[0] = buffer;

context[CONTEXT_STATE] = STATE_OUTGOING;
Expand Down
0