ホーム › Security.Cryptography › CRYPT_RC4_KEY_STATE
CRYPT_RC4_KEY_STATE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Key | BYTE | 16 | +0 | +0 | RC4の鍵データ(固定長配列)。 |
| SBox | BYTE | 256 | +16 | +16 | RC4の状態テーブル(Sボックス、256バイト)。 |
| i | BYTE | 1 | +272 | +272 | RC4ストリーム生成のインデックスi。 |
| j | BYTE | 1 | +273 | +273 | RC4ストリーム生成のインデックスj。 |
各言語での定義
#include <windows.h>
// CRYPT_RC4_KEY_STATE (x64 274 / x86 274 バイト)
typedef struct CRYPT_RC4_KEY_STATE {
BYTE Key[16];
BYTE SBox[256];
BYTE i;
BYTE j;
} CRYPT_RC4_KEY_STATE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPT_RC4_KEY_STATE
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] Key;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] SBox;
public byte i;
public byte j;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CRYPT_RC4_KEY_STATE
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public Key() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Public SBox() As Byte
Public i As Byte
Public j As Byte
End Structureimport ctypes
from ctypes import wintypes
class CRYPT_RC4_KEY_STATE(ctypes.Structure):
_fields_ = [
("Key", ctypes.c_ubyte * 16),
("SBox", ctypes.c_ubyte * 256),
("i", ctypes.c_ubyte),
("j", ctypes.c_ubyte),
]#[repr(C)]
pub struct CRYPT_RC4_KEY_STATE {
pub Key: [u8; 16],
pub SBox: [u8; 256],
pub i: u8,
pub j: u8,
}import "golang.org/x/sys/windows"
type CRYPT_RC4_KEY_STATE struct {
Key [16]byte
SBox [256]byte
i byte
j byte
}type
CRYPT_RC4_KEY_STATE = record
Key: array[0..15] of Byte;
SBox: array[0..255] of Byte;
i: Byte;
j: Byte;
end;const CRYPT_RC4_KEY_STATE = extern struct {
Key: [16]u8,
SBox: [256]u8,
i: u8,
j: u8,
};type
CRYPT_RC4_KEY_STATE {.bycopy.} = object
Key: array[16, uint8]
SBox: array[256, uint8]
i: uint8
j: uint8struct CRYPT_RC4_KEY_STATE
{
ubyte[16] Key;
ubyte[256] SBox;
ubyte i;
ubyte j;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CRYPT_RC4_KEY_STATE サイズ: 274 バイト(x64)
dim st, 69 ; 4byte整数×69(構造体サイズ 274 / 4 切り上げ)
; Key : BYTE (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; SBox : BYTE (+16, 256byte) varptr(st)+16 を基点に操作(256byte:入れ子/配列)
; i : BYTE (+272, 1byte) poke st,272,値 / 値 = peek(st,272)
; j : BYTE (+273, 1byte) poke st,273,値 / 値 = peek(st,273)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CRYPT_RC4_KEY_STATE
#field byte Key 16
#field byte SBox 256
#field byte i
#field byte j
#endstruct
stdim st, CRYPT_RC4_KEY_STATE ; NSTRUCT 変数を確保
st->i = 100
mes "i=" + st->i