Q:EVP_DecryptFinal_ex

Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
Error: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
at Decipheriv.final (node:internal/crypto/cipher:193:29)
at decrypt (D:\ApplicationsRoot\apps\RG3.Web.Host.PaaS\AppNodeJs\Plugins\app_crypto.js:52:25)
at C:\Users\Administrator\AppData\Local\Temp\2\4n2qc5j2.tsu:166:18
at IncomingMessage. (C:\Users\Administrator\AppData\Local\Temp\2\4n2qc5j2.tsu:186:37)
at IncomingMessage.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.InvokeExportAsync[T](NodeInvocationInfo invocationInfo, CancellationToken cancellationToken)

使用openssl中的aes进行加密和解密,使用相同的密钥但是出现下面的错误日志:
139868329146176:error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length:crypto/evp/evp_enc.c:559
结论
aes 256 cbc使用的密钥是32字节,iv是16字节,请确定加密和解密使用的密钥32字节都相同和iv的16字节都相同,而不是字符串长度。

分析
相应的分析文章
https://liwugang.github.io/2019/04/21/openssl_decrypt_fail.html

文档更新时间: 2023-06-12 09:46   作者:admin