ホーム › NetworkManagement.Dns › DNS_KEY_DATA
DNS_KEY_DATA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| wFlags | WORD | 2 | +0 | +0 | 鍵の用途や種別を示すDNSKEY/KEYフラグ値を保持する。 |
| chProtocol | BYTE | 1 | +2 | +2 | 鍵が使用されるプロトコルを示す。DNSSECでは値3。 |
| chAlgorithm | BYTE | 1 | +3 | +3 | 鍵の暗号アルゴリズム識別番号を示す。 |
| wKeyLength | WORD | 2 | +4 | +4 | Key配列に格納された公開鍵データのバイト長を示す。 |
| wPad | WORD | 2 | +6 | +6 | アラインメント調整用のパディング。値は通常0。 |
| Key | BYTE | 1 | +8 | +8 | 公開鍵の生バイト列を保持する可変長配列の先頭。 |
各言語での定義
#include <windows.h>
// DNS_KEY_DATA (x64 10 / x86 10 バイト)
typedef struct DNS_KEY_DATA {
WORD wFlags;
BYTE chProtocol;
BYTE chAlgorithm;
WORD wKeyLength;
WORD wPad;
BYTE Key[1];
} DNS_KEY_DATA;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_KEY_DATA
{
public ushort wFlags;
public byte chProtocol;
public byte chAlgorithm;
public ushort wKeyLength;
public ushort wPad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Key;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_KEY_DATA
Public wFlags As UShort
Public chProtocol As Byte
Public chAlgorithm As Byte
Public wKeyLength As UShort
Public wPad As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Key() As Byte
End Structureimport ctypes
from ctypes import wintypes
class DNS_KEY_DATA(ctypes.Structure):
_fields_ = [
("wFlags", ctypes.c_ushort),
("chProtocol", ctypes.c_ubyte),
("chAlgorithm", ctypes.c_ubyte),
("wKeyLength", ctypes.c_ushort),
("wPad", ctypes.c_ushort),
("Key", ctypes.c_ubyte * 1),
]#[repr(C)]
pub struct DNS_KEY_DATA {
pub wFlags: u16,
pub chProtocol: u8,
pub chAlgorithm: u8,
pub wKeyLength: u16,
pub wPad: u16,
pub Key: [u8; 1],
}import "golang.org/x/sys/windows"
type DNS_KEY_DATA struct {
wFlags uint16
chProtocol byte
chAlgorithm byte
wKeyLength uint16
wPad uint16
Key [1]byte
}type
DNS_KEY_DATA = record
wFlags: Word;
chProtocol: Byte;
chAlgorithm: Byte;
wKeyLength: Word;
wPad: Word;
Key: array[0..0] of Byte;
end;const DNS_KEY_DATA = extern struct {
wFlags: u16,
chProtocol: u8,
chAlgorithm: u8,
wKeyLength: u16,
wPad: u16,
Key: [1]u8,
};type
DNS_KEY_DATA {.bycopy.} = object
wFlags: uint16
chProtocol: uint8
chAlgorithm: uint8
wKeyLength: uint16
wPad: uint16
Key: array[1, uint8]struct DNS_KEY_DATA
{
ushort wFlags;
ubyte chProtocol;
ubyte chAlgorithm;
ushort wKeyLength;
ushort wPad;
ubyte[1] Key;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_KEY_DATA サイズ: 10 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 10 / 4 切り上げ)
; wFlags : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; chProtocol : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; chAlgorithm : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; wKeyLength : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; wPad : WORD (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; Key : BYTE (+8, 1byte) varptr(st)+8 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_KEY_DATA
#field short wFlags
#field byte chProtocol
#field byte chAlgorithm
#field short wKeyLength
#field short wPad
#field byte Key 1
#endstruct
stdim st, DNS_KEY_DATA ; NSTRUCT 変数を確保
st->wFlags = 100
mes "wFlags=" + st->wFlags