I am using AES CBC decryption in java using javax.crypto. I use the following methods of the Cipher class:
public final void init (int opmode, Key key, AlgorithmParameters params)
final int update(byte[] input, int inputOffset, int inputLen, byte[] output)
final int doFinal(byte[] output, int outputOffset)
My query is this: can I assume that the size of the data returned to me by the call doFinalwill always be less than or equal to the size of the AES block? The documentation describes the doFinal method as:
doFinal
"Finishes the multipart conversion (encryption or decryption). Processes any bytes that may have been buffered in previous update calls. Final converted bytes are stored in the output buffer."
But nowhere is it said that the output buffer will contain no more than one block of data. Although I understand that this is the general behavior of the AES API, and this is the behavior that my code has shown so far, but will this assumption always be fulfilled?
In general (as in the context of a class Cipher), I do not think it would be safe to assume this. According to javadocs for this method doFinal:
Cipher
, , ShortBufferException. . getOutputSize, , .
, "" , doFinal, getOutputSize . .
getOutputSize
, "", , , . ( , Java) Cipher , , getOutputSize .
, CBC, update? doFinal, ?
update
, , ; , , . "PKCS # 5" n ( n), n . , . CTS 2n . Java, , CTS, .
Cipher.getOutputSize(len) , len . , , , , , .
Cipher.getOutputSize(len)
len
, , ( ). , : ( ) ; , doFinal(). , getOutputSize() .
doFinal()
getOutputSize()
Source: https://habr.com/ru/post/1759490/More articles:Eclipse Source Control Module for Team Foundation Server 2008 - tfsИспользование букв нижнего регистра - htmlGrammar versus semantic analysis - compiler-constructionT-SQL Problem with SELECT TOP (case [...]) - tsqlIs it possible to distract this logic with a macro? - c ++C # Copy directory to another server - c #Как проверить правильность XML в отношении XML-схемы в ActionScript? - flexWhich SCM can conveniently handle 90,000 files - gitWhat is the point of writing a dynamic query in a stored procedure - sql.NET version of Java assertGC: tesing module memory leaks - garbage-collectionAll Articles