Win32 API 日本語リファレンス
ホームSecurity.Cryptography › CRYPT_AES_128_KEY_STATE

CRYPT_AES_128_KEY_STATE

構造体
サイズx64: 400 バイト / x86: 400 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
KeyBYTE16+0+0AES-128の鍵データ(固定長配列)。
IVBYTE16+16+16AES-128の初期化ベクトル(固定長配列)。
EncryptionStateBYTE176+32+32暗号化処理の内部状態データ(固定長配列)。
DecryptionStateBYTE176+208+208復号処理の内部状態データ(固定長配列)。
FeedbackBYTE16+384+384暗号化フィードバックの状態データ(固定長配列)。

各言語での定義

#include <windows.h>

// CRYPT_AES_128_KEY_STATE  (x64 400 / x86 400 バイト)
typedef struct CRYPT_AES_128_KEY_STATE {
    BYTE Key[16];
    BYTE IV[16];
    BYTE EncryptionState[176];
    BYTE DecryptionState[176];
    BYTE Feedback[16];
} CRYPT_AES_128_KEY_STATE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_AES_128_KEY_STATE
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] Key;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] IV;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 176)] public byte[] EncryptionState;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 176)] public byte[] DecryptionState;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] Feedback;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_AES_128_KEY_STATE
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public Key() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public IV() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=176)> Public EncryptionState() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=176)> Public DecryptionState() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public Feedback() As Byte
End Structure
import ctypes
from ctypes import wintypes

class CRYPT_AES_128_KEY_STATE(ctypes.Structure):
    _fields_ = [
        ("Key", ctypes.c_ubyte * 16),
        ("IV", ctypes.c_ubyte * 16),
        ("EncryptionState", ctypes.c_ubyte * 176),
        ("DecryptionState", ctypes.c_ubyte * 176),
        ("Feedback", ctypes.c_ubyte * 16),
    ]
#[repr(C)]
pub struct CRYPT_AES_128_KEY_STATE {
    pub Key: [u8; 16],
    pub IV: [u8; 16],
    pub EncryptionState: [u8; 176],
    pub DecryptionState: [u8; 176],
    pub Feedback: [u8; 16],
}
import "golang.org/x/sys/windows"

type CRYPT_AES_128_KEY_STATE struct {
	Key [16]byte
	IV [16]byte
	EncryptionState [176]byte
	DecryptionState [176]byte
	Feedback [16]byte
}
type
  CRYPT_AES_128_KEY_STATE = record
    Key: array[0..15] of Byte;
    IV: array[0..15] of Byte;
    EncryptionState: array[0..175] of Byte;
    DecryptionState: array[0..175] of Byte;
    Feedback: array[0..15] of Byte;
  end;
const CRYPT_AES_128_KEY_STATE = extern struct {
    Key: [16]u8,
    IV: [16]u8,
    EncryptionState: [176]u8,
    DecryptionState: [176]u8,
    Feedback: [16]u8,
};
type
  CRYPT_AES_128_KEY_STATE {.bycopy.} = object
    Key: array[16, uint8]
    IV: array[16, uint8]
    EncryptionState: array[176, uint8]
    DecryptionState: array[176, uint8]
    Feedback: array[16, uint8]
struct CRYPT_AES_128_KEY_STATE
{
    ubyte[16] Key;
    ubyte[16] IV;
    ubyte[176] EncryptionState;
    ubyte[176] DecryptionState;
    ubyte[16] Feedback;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CRYPT_AES_128_KEY_STATE サイズ: 400 バイト(x64)
dim st, 100    ; 4byte整数×100(構造体サイズ 400 / 4 切り上げ)
; Key : BYTE (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; IV : BYTE (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; EncryptionState : BYTE (+32, 176byte)  varptr(st)+32 を基点に操作(176byte:入れ子/配列)
; DecryptionState : BYTE (+208, 176byte)  varptr(st)+208 を基点に操作(176byte:入れ子/配列)
; Feedback : BYTE (+384, 16byte)  varptr(st)+384 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CRYPT_AES_128_KEY_STATE
    #field byte Key 16
    #field byte IV 16
    #field byte EncryptionState 176
    #field byte DecryptionState 176
    #field byte Feedback 16
#endstruct

stdim st, CRYPT_AES_128_KEY_STATE        ; NSTRUCT 変数を確保