Skip to content

Commit 2f1adfa

Browse files
author
liyongfei
committed
Documentation Update: Clarify SM2/SM9 Encryption and Decryption Processes
1 parent 228f05a commit 2f1adfa

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/main/java/org/gmssl/crypto/asymmetric/SM2Cipher.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) {
117117
return null;
118118
}
119119

120+
/**
121+
* 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`.
122+
* @param input the input buffer
123+
* @param inputOffset the offset in <code>input</code> where the input
124+
* starts
125+
* @param inputLen the input length
126+
* @param output the buffer for the result
127+
* @param outputOffset the offset in <code>output</code> where the result
128+
* is stored
129+
*
130+
* @return
131+
* @throws ShortBufferException
132+
*/
120133
@Override
121134
protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException {
122135
if (input == null || inputOffset < 0 || inputLen < 0 || inputOffset + inputLen > input.length) {

src/main/java/org/gmssl/crypto/asymmetric/SM9Cipher.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,12 @@ protected void engineInit(int opmode, Key key, AlgorithmParameters params, Secur
109109
}
110110

111111
/**
112-
*
112+
* 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.
113113
* @param input the input buffer
114114
* @param inputOffset the offset in <code>input</code> where the input
115115
* starts
116116
* @param inputLen the input length
117-
* @description
118-
* 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.
117+
*
119118
* @return
120119
*/
121120
@Override
@@ -124,6 +123,19 @@ protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) {
124123
return null;
125124
}
126125

126+
/**
127+
* 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.
128+
* @param input the input buffer
129+
* @param inputOffset the offset in <code>input</code> where the input
130+
* starts
131+
* @param inputLen the input length
132+
* @param output the buffer for the result
133+
* @param outputOffset the offset in <code>output</code> where the result
134+
* is stored
135+
*
136+
* @return
137+
* @throws ShortBufferException
138+
*/
127139
@Override
128140
protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException {
129141
buffer.put(input, inputOffset, inputLen);

0 commit comments

Comments
 (0)