CryptoSys PKI Pro Manual

Example: Cipher.KeyWrap 

[VB6 equivalent: CIPHER_KeyWrap]

Dim abWK() As Byte
Dim abKeyData() As Byte
Dim abKek() As Byte

abKeyData = Cnv.FromHex("00112233 44556677 8899aabb ccddeeff")
abKek = Cnv.FromHex("c17a44e8 e28d7d64 81d1ddd5 0a3b8914")

abWK = Cipher.KeyWrap(abKeyData, abKek, CipherAlgorithm.Aes128)
If abWK.Length = 0 Then
    Console.WriteLine("Cipher.KeyWrap: " & General.LastError())
    Exit Sub
End If
Console.WriteLine("WK=" & Cnv.ToHex(abWK))

abKeyData = Cnv.FromHex("8cbedec4 8d063e1b a46be8e3 69a9c398 d8e30ee5 42bc347c 4f30e928 ddd7db49")
abKek = Cnv.FromHex("9e84ee99 e6a84b50 c76cd414 a2d2ec05 8af41bfe 4bf3715b f894c8da 1cd445f6")

abWK = Cipher.KeyWrap(abKeyData, abKek, CipherAlgorithm.Aes256)
If abWK.Length = 0 Then
    Console.WriteLine("Cipher.KeyWrap: " & General.LastError())
    Exit Sub
End If
Console.WriteLine("WK=" & Cnv.ToHex(abWK))

abKeyData = Cnv.FromHex("84e7f2d8 78f89fcc cd2d5eba fc56daf7 3300f27e f771cd68")
abKek = Cnv.FromHex("8ad8274e 56f46773 8edd83d4 394e5e29 af7c4089 e4f8d9f4")

abWK = Cipher.KeyWrap(abKeyData, abKek, CipherAlgorithm.Tdea)
If abWK.Length = 0 Then
    Console.WriteLine("Cipher.KeyWrap: " & General.LastError())
    Exit Sub
End If
Console.WriteLine("WK=" & Cnv.ToHex(abWK))

See Also:
Cipher.KeyWrap Method

[Contents] [Index]

[PREV: Example: Cipher.Decrypt ...]   [Contents]   [Index]   
   [NEXT: Example: Cipher.KeyUnwrap ...]

Copyright © 2004-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-09-18T10:02:53Z.