ホーム › Security.Authentication.Identity › KERB_DECRYPT_REQUEST
KERB_DECRYPT_REQUEST
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| MessageType | KERB_PROTOCOL_MESSAGE_TYPE | 4 | +0 | +0 | Kerberos要求種別を示す値で、KerbDecryptDataMessage を指定する。 |
| LogonId | LUID | 8 | +4 | +4 | 復号に用いるセッション鍵を持つログオンセッションのLUID。 |
| Flags | DWORD | 4 | +12 | +12 | 復号動作を制御するビットフラグ。通常はゼロで予約されている。 |
| CryptoType | INT | 4 | +16 | +16 | 使用する暗号方式の種別を示す整数値(暗号化タイプID)。 |
| KeyUsage | INT | 4 | +20 | +20 | Kerberos鍵使用番号で、暗号化文脈を区別する整数値。 |
| Key | KERB_CRYPTO_KEY | 16/12 | +24 | +24 | 復号に用いる暗号鍵を保持するKERB_CRYPTO_KEY構造体。 |
| EncryptedDataSize | DWORD | 4 | +40 | +36 | EncryptedDataが指す暗号化データのバイト数。 |
| InitialVectorSize | DWORD | 4 | +44 | +40 | InitialVectorが指す初期化ベクトルのバイト数。ゼロ可。 |
| InitialVector | BYTE* | 8/4 | +48 | +44 | 復号に用いる初期化ベクトル(IV)を指すバイト配列ポインタ。NULL可。 |
| EncryptedData | BYTE* | 8/4 | +56 | +48 | 復号対象の暗号化データを指すバイト配列ポインタ。 |
各言語での定義
#include <windows.h>
// LUID (x64 8 / x86 8 バイト)
typedef struct LUID {
DWORD LowPart;
INT HighPart;
} LUID;
// KERB_CRYPTO_KEY (x64 16 / x86 12 バイト)
typedef struct KERB_CRYPTO_KEY {
KERB_CRYPTO_KEY_TYPE KeyType;
DWORD Length;
BYTE* Value;
} KERB_CRYPTO_KEY;
// KERB_DECRYPT_REQUEST (x64 64 / x86 52 バイト)
typedef struct KERB_DECRYPT_REQUEST {
KERB_PROTOCOL_MESSAGE_TYPE MessageType;
LUID LogonId;
DWORD Flags;
INT CryptoType;
INT KeyUsage;
KERB_CRYPTO_KEY Key;
DWORD EncryptedDataSize;
DWORD InitialVectorSize;
BYTE* InitialVector;
BYTE* EncryptedData;
} KERB_DECRYPT_REQUEST;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LUID
{
public uint LowPart;
public int HighPart;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERB_CRYPTO_KEY
{
public int KeyType;
public uint Length;
public IntPtr Value;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERB_DECRYPT_REQUEST
{
public int MessageType;
public LUID LogonId;
public uint Flags;
public int CryptoType;
public int KeyUsage;
public KERB_CRYPTO_KEY Key;
public uint EncryptedDataSize;
public uint InitialVectorSize;
public IntPtr InitialVector;
public IntPtr EncryptedData;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LUID
Public LowPart As UInteger
Public HighPart As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERB_CRYPTO_KEY
Public KeyType As Integer
Public Length As UInteger
Public Value As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERB_DECRYPT_REQUEST
Public MessageType As Integer
Public LogonId As LUID
Public Flags As UInteger
Public CryptoType As Integer
Public KeyUsage As Integer
Public Key As KERB_CRYPTO_KEY
Public EncryptedDataSize As UInteger
Public InitialVectorSize As UInteger
Public InitialVector As IntPtr
Public EncryptedData As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class LUID(ctypes.Structure):
_fields_ = [
("LowPart", wintypes.DWORD),
("HighPart", ctypes.c_int),
]
class KERB_CRYPTO_KEY(ctypes.Structure):
_fields_ = [
("KeyType", ctypes.c_int),
("Length", wintypes.DWORD),
("Value", ctypes.c_void_p),
]
class KERB_DECRYPT_REQUEST(ctypes.Structure):
_fields_ = [
("MessageType", ctypes.c_int),
("LogonId", LUID),
("Flags", wintypes.DWORD),
("CryptoType", ctypes.c_int),
("KeyUsage", ctypes.c_int),
("Key", KERB_CRYPTO_KEY),
("EncryptedDataSize", wintypes.DWORD),
("InitialVectorSize", wintypes.DWORD),
("InitialVector", ctypes.c_void_p),
("EncryptedData", ctypes.c_void_p),
]#[repr(C)]
pub struct LUID {
pub LowPart: u32,
pub HighPart: i32,
}
#[repr(C)]
pub struct KERB_CRYPTO_KEY {
pub KeyType: i32,
pub Length: u32,
pub Value: *mut core::ffi::c_void,
}
#[repr(C)]
pub struct KERB_DECRYPT_REQUEST {
pub MessageType: i32,
pub LogonId: LUID,
pub Flags: u32,
pub CryptoType: i32,
pub KeyUsage: i32,
pub Key: KERB_CRYPTO_KEY,
pub EncryptedDataSize: u32,
pub InitialVectorSize: u32,
pub InitialVector: *mut core::ffi::c_void,
pub EncryptedData: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type LUID struct {
LowPart uint32
HighPart int32
}
type KERB_CRYPTO_KEY struct {
KeyType int32
Length uint32
Value uintptr
}
type KERB_DECRYPT_REQUEST struct {
MessageType int32
LogonId LUID
Flags uint32
CryptoType int32
KeyUsage int32
Key KERB_CRYPTO_KEY
EncryptedDataSize uint32
InitialVectorSize uint32
InitialVector uintptr
EncryptedData uintptr
}type
LUID = record
LowPart: DWORD;
HighPart: Integer;
end;
KERB_CRYPTO_KEY = record
KeyType: Integer;
Length: DWORD;
Value: Pointer;
end;
KERB_DECRYPT_REQUEST = record
MessageType: Integer;
LogonId: LUID;
Flags: DWORD;
CryptoType: Integer;
KeyUsage: Integer;
Key: KERB_CRYPTO_KEY;
EncryptedDataSize: DWORD;
InitialVectorSize: DWORD;
InitialVector: Pointer;
EncryptedData: Pointer;
end;const LUID = extern struct {
LowPart: u32,
HighPart: i32,
};
const KERB_CRYPTO_KEY = extern struct {
KeyType: i32,
Length: u32,
Value: ?*anyopaque,
};
const KERB_DECRYPT_REQUEST = extern struct {
MessageType: i32,
LogonId: LUID,
Flags: u32,
CryptoType: i32,
KeyUsage: i32,
Key: KERB_CRYPTO_KEY,
EncryptedDataSize: u32,
InitialVectorSize: u32,
InitialVector: ?*anyopaque,
EncryptedData: ?*anyopaque,
};type
LUID {.bycopy.} = object
LowPart: uint32
HighPart: int32
KERB_CRYPTO_KEY {.bycopy.} = object
KeyType: int32
Length: uint32
Value: pointer
KERB_DECRYPT_REQUEST {.bycopy.} = object
MessageType: int32
LogonId: LUID
Flags: uint32
CryptoType: int32
KeyUsage: int32
Key: KERB_CRYPTO_KEY
EncryptedDataSize: uint32
InitialVectorSize: uint32
InitialVector: pointer
EncryptedData: pointerstruct LUID
{
uint LowPart;
int HighPart;
}
struct KERB_CRYPTO_KEY
{
int KeyType;
uint Length;
void* Value;
}
struct KERB_DECRYPT_REQUEST
{
int MessageType;
LUID LogonId;
uint Flags;
int CryptoType;
int KeyUsage;
KERB_CRYPTO_KEY Key;
uint EncryptedDataSize;
uint InitialVectorSize;
void* InitialVector;
void* EncryptedData;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; KERB_DECRYPT_REQUEST サイズ: 52 バイト(x86)
dim st, 13 ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; MessageType : KERB_PROTOCOL_MESSAGE_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; LogonId : LUID (+4, 8byte) varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; Flags : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; CryptoType : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; KeyUsage : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; Key : KERB_CRYPTO_KEY (+24, 12byte) varptr(st)+24 を基点に操作(12byte:入れ子/配列)
; EncryptedDataSize : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; InitialVectorSize : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; InitialVector : BYTE* (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; EncryptedData : BYTE* (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; KERB_DECRYPT_REQUEST サイズ: 64 バイト(x64)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; MessageType : KERB_PROTOCOL_MESSAGE_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; LogonId : LUID (+4, 8byte) varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; Flags : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; CryptoType : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; KeyUsage : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; Key : KERB_CRYPTO_KEY (+24, 16byte) varptr(st)+24 を基点に操作(16byte:入れ子/配列)
; EncryptedDataSize : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; InitialVectorSize : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; InitialVector : BYTE* (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; EncryptedData : BYTE* (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global LUID
#field int LowPart
#field int HighPart
#endstruct
#defstruct global KERB_CRYPTO_KEY
#field int KeyType
#field int Length
#field intptr Value
#endstruct
#defstruct global KERB_DECRYPT_REQUEST
#field int MessageType
#field LUID LogonId
#field int Flags
#field int CryptoType
#field int KeyUsage
#field KERB_CRYPTO_KEY Key
#field int EncryptedDataSize
#field int InitialVectorSize
#field intptr InitialVector
#field intptr EncryptedData
#endstruct
stdim st, KERB_DECRYPT_REQUEST ; NSTRUCT 変数を確保
st->MessageType = 100
mes "MessageType=" + st->MessageType