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>
* // Create a context using default credentials
* // and the implementation specific default mechanism
* GSSManager manager ...
* GSSName targetName ...
* GSSManager manager = ...
* GSSName targetName = ...
* GSSContext context = manager.createContext(targetName, null, null,
* GSSContext.INDEFINITE_LIFETIME);
*
@ -141,21 +141,23 @@ import java.io.OutputStream;
*
* // 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
*
* while (!context.isEstablished()) {
*
* byte[] outToken
* = context.initSecContext(inToken, 0, inToken.length);
* outToken = context.initSecContext(inToken, 0, inToken.length);
*
* // send the output token if generated
* if (outToken != null)
* if (outToken != null) {
* sendToken(outToken);
* }
*
* if (!context.isEstablished()) {
* inToken = readToken();
* }
* }
*
* // display context information
@ -165,21 +167,40 @@ import java.io.OutputStream;
* System.out.println("Initiator = " + context.getSrcName());
* System.out.println("Acceptor = " + context.getTargName());
*
* if (context.getConfState())
* System.out.println("Confidentiality (i.e., privacy) is available");
* if (context.getConfState()) {
* System.out.println("Confidentiality (i.e., privacy) is available");
* }
*
* if (context.getIntegState())
* System.out.println("Integrity is available");
* if (context.getIntegState()) {
* System.out.println("Integrity is available");
* }
*
* // perform wrap on an application supplied message, appMsg,
* // using QOP = 0, and requesting privacy service
* byte [] appMsg ...
* byte[] appMsg = ...
*
* 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
* context.dispose();