Skip to content

Commit

Permalink
Documentation Update: Clarify SM2/SM9 Encryption and Decryption Proce…
Browse files Browse the repository at this point in the history
…sses
  • Loading branch information
liyongfei committed Sep 23, 2024
1 parent 228f05a commit 2f1adfa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/gmssl/crypto/asymmetric/SM2Cipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) {
return null;
}

/**
* The method does not perform any encryption or decryption; it only stores the input data. The returned result is meaningless, and the final result is output through `doFinal`.
* @param input the input buffer
* @param inputOffset the offset in <code>input</code> where the input
* starts
* @param inputLen the input length
* @param output the buffer for the result
* @param outputOffset the offset in <code>output</code> where the result
* is stored
*
* @return
* @throws ShortBufferException
*/
@Override
protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException {
if (input == null || inputOffset < 0 || inputLen < 0 || inputOffset + inputLen > input.length) {
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/org/gmssl/crypto/asymmetric/SM9Cipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ protected void engineInit(int opmode, Key key, AlgorithmParameters params, Secur
}

/**
*
* SM9 encryption and decryption are completed during the engineDoFinal phase. During the update phase, data is only cached, and no partial encryption or decryption results are returned.
* @param input the input buffer
* @param inputOffset the offset in <code>input</code> where the input
* starts
* @param inputLen the input length
* @description
* SM9 encryption and decryption are completed during the engineDoFinal phase. During the update phase, data is only cached, and no partial encryption or decryption results are returned.
*
* @return
*/
@Override
Expand All @@ -124,6 +123,19 @@ protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) {
return null;
}

/**
* SM9 encryption and decryption are completed during the engineDoFinal phase. During the update phase, data is only cached, and no partial encryption or decryption results are returned.
* @param input the input buffer
* @param inputOffset the offset in <code>input</code> where the input
* starts
* @param inputLen the input length
* @param output the buffer for the result
* @param outputOffset the offset in <code>output</code> where the result
* is stored
*
* @return
* @throws ShortBufferException
*/
@Override
protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException {
buffer.put(input, inputOffset, inputLen);
Expand Down

0 comments on commit 2f1adfa

Please sign in to comment.