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

CRYPT_AES_256_KEY_STATE

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

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

フィールド

フィールドサイズx64x86説明
KeyBYTE32+0+0AES-256の鍵データ(固定長配列)。
IVBYTE16+32+32AES-256の初期化ベクトル(固定長配列)。
EncryptionStateBYTE240+48+48暗号化処理の内部状態データ(固定長配列)。
DecryptionStateBYTE240+288+288復号処理の内部状態データ(固定長配列)。
FeedbackBYTE16+528+528暗号化フィードバックの状態データ(固定長配列)。

各言語での定義

#include <windows.h>

// CRYPT_AES_256_KEY_STATE  (x64 544 / x86 544 バイト)
typedef struct CRYPT_AES_256_KEY_STATE {
    BYTE Key[32];
    BYTE IV[16];
    BYTE EncryptionState[240];
    BYTE DecryptionState[240];
    BYTE Feedback[16];
} CRYPT_AES_256_KEY_STATE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_AES_256_KEY_STATE
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] Key;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] IV;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 240)] public byte[] EncryptionState;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 240)] 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_256_KEY_STATE
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public Key() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public IV() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=240)> Public EncryptionState() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=240)> Public DecryptionState() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public Feedback() As Byte
End Structure
import ctypes
from ctypes import wintypes

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

type CRYPT_AES_256_KEY_STATE struct {
	Key [32]byte
	IV [16]byte
	EncryptionState [240]byte
	DecryptionState [240]byte
	Feedback [16]byte
}
type
  CRYPT_AES_256_KEY_STATE = record
    Key: array[0..31] of Byte;
    IV: array[0..15] of Byte;
    EncryptionState: array[0..239] of Byte;
    DecryptionState: array[0..239] of Byte;
    Feedback: array[0..15] of Byte;
  end;
const CRYPT_AES_256_KEY_STATE = extern struct {
    Key: [32]u8,
    IV: [16]u8,
    EncryptionState: [240]u8,
    DecryptionState: [240]u8,
    Feedback: [16]u8,
};
type
  CRYPT_AES_256_KEY_STATE {.bycopy.} = object
    Key: array[32, uint8]
    IV: array[16, uint8]
    EncryptionState: array[240, uint8]
    DecryptionState: array[240, uint8]
    Feedback: array[16, uint8]
struct CRYPT_AES_256_KEY_STATE
{
    ubyte[32] Key;
    ubyte[16] IV;
    ubyte[240] EncryptionState;
    ubyte[240] 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_256_KEY_STATE サイズ: 544 バイト(x64)
dim st, 136    ; 4byte整数×136(構造体サイズ 544 / 4 切り上げ)
; Key : BYTE (+0, 32byte)  varptr(st)+0 を基点に操作(32byte:入れ子/配列)
; IV : BYTE (+32, 16byte)  varptr(st)+32 を基点に操作(16byte:入れ子/配列)
; EncryptionState : BYTE (+48, 240byte)  varptr(st)+48 を基点に操作(240byte:入れ子/配列)
; DecryptionState : BYTE (+288, 240byte)  varptr(st)+288 を基点に操作(240byte:入れ子/配列)
; Feedback : BYTE (+528, 16byte)  varptr(st)+528 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CRYPT_AES_256_KEY_STATE
    #field byte Key 32
    #field byte IV 16
    #field byte EncryptionState 240
    #field byte DecryptionState 240
    #field byte Feedback 16
#endstruct

stdim st, CRYPT_AES_256_KEY_STATE        ; NSTRUCT 変数を確保