8226963: More clarification on possible sequencing error in GSSContext::unwrap

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2019-07-04 07:25:47 +08:00
parent c0fddce0f5
commit 77a6a6e1ae

View file

@ -128,8 +128,8 @@ import java.io.OutputStream;
* <pre> * <pre>
* // Create a context using default credentials * // Create a context using default credentials
* // and the implementation specific default mechanism * // and the implementation specific default mechanism
* GSSManager manager ... * GSSManager manager = ...
* GSSName targetName ... * GSSName targetName = ...
* GSSContext context = manager.createContext(targetName, null, null, * GSSContext context = manager.createContext(targetName, null, null,
* GSSContext.INDEFINITE_LIFETIME); * GSSContext.INDEFINITE_LIFETIME);
* *
@ -141,21 +141,23 @@ import java.io.OutputStream;
* *
* // establish a context between peers * // establish a context between peers
* *
* byte []inToken = new byte[0]; * byte[] inToken = new byte[0];
* byte[] outToken;
* *
* // Loop while there still is a token to be processed * // Loop while there still is a token to be processed
* *
* while (!context.isEstablished()) { * while (!context.isEstablished()) {
* *
* byte[] outToken * outToken = context.initSecContext(inToken, 0, inToken.length);
* = context.initSecContext(inToken, 0, inToken.length);
* *
* // send the output token if generated * // send the output token if generated
* if (outToken != null) * if (outToken != null) {
* sendToken(outToken); * sendToken(outToken);
* }
* *
* if (!context.isEstablished()) { * if (!context.isEstablished()) {
* inToken = readToken(); * inToken = readToken();
* }
* } * }
* *
* // display context information * // display context information
@ -165,21 +167,40 @@ import java.io.OutputStream;
* System.out.println("Initiator = " + context.getSrcName()); * System.out.println("Initiator = " + context.getSrcName());
* System.out.println("Acceptor = " + context.getTargName()); * System.out.println("Acceptor = " + context.getTargName());
* *
* if (context.getConfState()) * if (context.getConfState()) {
* System.out.println("Confidentiality (i.e., privacy) is available"); * System.out.println("Confidentiality (i.e., privacy) is available");
* }
* *
* if (context.getIntegState()) * if (context.getIntegState()) {
* System.out.println("Integrity is available"); * System.out.println("Integrity is available");
* }
* *
* // perform wrap on an application supplied message, appMsg, * // perform wrap on an application supplied message, appMsg,
* // using QOP = 0, and requesting privacy service * // using QOP = 0, and requesting privacy service
* byte [] appMsg ... * byte[] appMsg = ...
* *
* MessageProp mProp = new MessageProp(0, true); * MessageProp mProp = new MessageProp(0, true);
* *
* byte []tok = context.wrap(appMsg, 0, appMsg.length, mProp); * outToken = context.wrap(appMsg, 0, appMsg.length, mProp);
* *
* sendToken(tok); * sendToken(outToken);
*
* // perform unwrap on an incoming application message, and check
* // its privacy state and supplementary information
* inToken = readToken();
*
* mProp = new MessageProp(0, true);
*
* appMsg = context.unwrap(inToken, 0, inToken.length, mProp);
*
* System.out.println("Was it encrypted? " + mProp.getPrivacy());
* System.out.println("Duplicate Token? " + mProp.isDuplicateToken());
* System.out.println("Old Token? " + mProp.isOldToken());
* System.out.println("Unsequenced Token? " + mProp.isUnseqToken());
* System.out.println("Gap Token? " + mProp.isGapToken());
*
* // the application determines if the privacy state and supplementary
* // information are acceptable
* *
* // release the local-end of the context * // release the local-end of the context
* context.dispose(); * context.dispose();