我有一段代码用AES密钥包装对称密钥(AES):
码:
SecretKey swkKeySpec = new SecretKeySpec(swkKey, 0, swkKey.length, "AES");
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding", "BC");
final int ivLength = 12;
final IvParameterSpec iv = createIV(ivLength);///Creates a new array.
cipher.init(Cipher.WRAP_MODE, swkKeySpec, iv);
SecretKey sKeySpec = new SecretKeySpec(key, 0, key.length, "AES");
byte[] wrappedAppKey = cipher.wrap(sKeySpec);`
Run Code Online (Sandbox Code Playgroud)
如果key是256位,而swkkey是256位,则wrappedAppKey的长度是多少。包装的密钥可以超过32个字节吗?请注意,在这种情况下,我将收到以下日志:
key length: 32(key to be wrapped)
swkKey length: 32(key used to wrap)
wrappedAppKey size: 48(final wrapped key output).
Run Code Online (Sandbox Code Playgroud)