ホーム › Security.Cryptography › BCryptGetFipsAlgorithmMode
BCryptGetFipsAlgorithmMode
関数FIPS準拠アルゴリズムモードが有効かどうかを取得する。
シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptGetFipsAlgorithmMode(
BYTE* pfEnabled
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pfEnabled | BYTE* | out | BOOLEAN 変数のアドレスです。FIPS 準拠が有効でない場合は 0 を、有効な場合は 0 以外の値を受け取ります。 |
戻り値の型: NTSTATUS
公式ドキュメント
連邦情報処理規格 (FIPS) への準拠が有効になっているかどうかを判定します。
戻り値
関数の成功または失敗を示すステータスコードを返します。
返される可能性のあるコードには、以下のものが含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| 関数は成功しました。 | |
| pfEnabled パラメーターが無効です。 |
解説(Remarks)
BCryptGetFipsAlgorithmMode は、ユーザーモードまたはカーネルモードのいずれからも呼び出すことができます。カーネルモードの呼び出し元は、PASSIVE_LEVEL の IRQL で実行されている必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptGetFipsAlgorithmMode(
BYTE* pfEnabled
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptGetFipsAlgorithmMode(
IntPtr pfEnabled // BYTE* out
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptGetFipsAlgorithmMode(
pfEnabled As IntPtr ' BYTE* out
) As Integer
End Function' pfEnabled : BYTE* out
Declare PtrSafe Function BCryptGetFipsAlgorithmMode Lib "bcrypt" ( _
ByVal pfEnabled As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptGetFipsAlgorithmMode = ctypes.windll.bcrypt.BCryptGetFipsAlgorithmMode
BCryptGetFipsAlgorithmMode.restype = ctypes.c_int
BCryptGetFipsAlgorithmMode.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # pfEnabled : BYTE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptGetFipsAlgorithmMode = Fiddle::Function.new(
lib['BCryptGetFipsAlgorithmMode'],
[
Fiddle::TYPE_VOIDP, # pfEnabled : BYTE* out
],
Fiddle::TYPE_INT)#[link(name = "bcrypt")]
extern "system" {
fn BCryptGetFipsAlgorithmMode(
pfEnabled: *mut u8 // BYTE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptGetFipsAlgorithmMode(IntPtr pfEnabled);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptGetFipsAlgorithmMode' -Namespace Win32 -PassThru
# $api::BCryptGetFipsAlgorithmMode(pfEnabled)#uselib "bcrypt.dll"
#func global BCryptGetFipsAlgorithmMode "BCryptGetFipsAlgorithmMode" sptr
; BCryptGetFipsAlgorithmMode varptr(pfEnabled) ; 戻り値は stat
; pfEnabled : BYTE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "bcrypt.dll" #cfunc global BCryptGetFipsAlgorithmMode "BCryptGetFipsAlgorithmMode" var ; res = BCryptGetFipsAlgorithmMode(pfEnabled) ; pfEnabled : BYTE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "bcrypt.dll" #cfunc global BCryptGetFipsAlgorithmMode "BCryptGetFipsAlgorithmMode" sptr ; res = BCryptGetFipsAlgorithmMode(varptr(pfEnabled)) ; pfEnabled : BYTE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS BCryptGetFipsAlgorithmMode(BYTE* pfEnabled) #uselib "bcrypt.dll" #cfunc global BCryptGetFipsAlgorithmMode "BCryptGetFipsAlgorithmMode" var ; res = BCryptGetFipsAlgorithmMode(pfEnabled) ; pfEnabled : BYTE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS BCryptGetFipsAlgorithmMode(BYTE* pfEnabled) #uselib "bcrypt.dll" #cfunc global BCryptGetFipsAlgorithmMode "BCryptGetFipsAlgorithmMode" intptr ; res = BCryptGetFipsAlgorithmMode(varptr(pfEnabled)) ; pfEnabled : BYTE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptGetFipsAlgorithmMode = bcrypt.NewProc("BCryptGetFipsAlgorithmMode")
)
// pfEnabled (BYTE* out)
r1, _, err := procBCryptGetFipsAlgorithmMode.Call(
uintptr(pfEnabled),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptGetFipsAlgorithmMode(
pfEnabled: Pointer // BYTE* out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptGetFipsAlgorithmMode';result := DllCall("bcrypt\BCryptGetFipsAlgorithmMode"
, "Ptr", pfEnabled ; BYTE* out
, "Int") ; return: NTSTATUS●BCryptGetFipsAlgorithmMode(pfEnabled) = DLL("bcrypt.dll", "int BCryptGetFipsAlgorithmMode(void*)")
# 呼び出し: BCryptGetFipsAlgorithmMode(pfEnabled)
# pfEnabled : BYTE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bcrypt" fn BCryptGetFipsAlgorithmMode(
pfEnabled: [*c]u8 // BYTE* out
) callconv(std.os.windows.WINAPI) i32;proc BCryptGetFipsAlgorithmMode(
pfEnabled: ptr uint8 # BYTE* out
): int32 {.importc: "BCryptGetFipsAlgorithmMode", stdcall, dynlib: "bcrypt.dll".}pragma(lib, "bcrypt");
extern(Windows)
int BCryptGetFipsAlgorithmMode(
ubyte* pfEnabled // BYTE* out
);ccall((:BCryptGetFipsAlgorithmMode, "bcrypt.dll"), stdcall, Int32,
(Ptr{UInt8},),
pfEnabled)
# pfEnabled : BYTE* out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BCryptGetFipsAlgorithmMode(
uint8_t* pfEnabled);
]]
local bcrypt = ffi.load("bcrypt")
-- bcrypt.BCryptGetFipsAlgorithmMode(pfEnabled)
-- pfEnabled : BYTE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('bcrypt.dll');
const BCryptGetFipsAlgorithmMode = lib.func('__stdcall', 'BCryptGetFipsAlgorithmMode', 'int32_t', ['uint8_t *']);
// BCryptGetFipsAlgorithmMode(pfEnabled)
// pfEnabled : BYTE* out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("bcrypt.dll", {
BCryptGetFipsAlgorithmMode: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.BCryptGetFipsAlgorithmMode(pfEnabled)
// pfEnabled : BYTE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BCryptGetFipsAlgorithmMode(
uint8_t* pfEnabled);
C, "bcrypt.dll");
// $ffi->BCryptGetFipsAlgorithmMode(pfEnabled);
// pfEnabled : BYTE* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Bcrypt extends StdCallLibrary {
Bcrypt INSTANCE = Native.load("bcrypt", Bcrypt.class);
int BCryptGetFipsAlgorithmMode(
byte[] pfEnabled // BYTE* out
);
}@[Link("bcrypt")]
lib Libbcrypt
fun BCryptGetFipsAlgorithmMode = BCryptGetFipsAlgorithmMode(
pfEnabled : UInt8* # BYTE* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BCryptGetFipsAlgorithmModeNative = Int32 Function(Pointer<Uint8>);
typedef BCryptGetFipsAlgorithmModeDart = int Function(Pointer<Uint8>);
final BCryptGetFipsAlgorithmMode = DynamicLibrary.open('bcrypt.dll')
.lookupFunction<BCryptGetFipsAlgorithmModeNative, BCryptGetFipsAlgorithmModeDart>('BCryptGetFipsAlgorithmMode');
// pfEnabled : BYTE* out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BCryptGetFipsAlgorithmMode(
pfEnabled: Pointer // BYTE* out
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptGetFipsAlgorithmMode';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BCryptGetFipsAlgorithmMode"
c_BCryptGetFipsAlgorithmMode :: Ptr Word8 -> IO Int32
-- pfEnabled : BYTE* out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcryptgetfipsalgorithmmode =
foreign "BCryptGetFipsAlgorithmMode"
((ptr uint8_t) @-> returning int32_t)
(* pfEnabled : BYTE* out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bcrypt (t "bcrypt.dll"))
(cffi:use-foreign-library bcrypt)
(cffi:defcfun ("BCryptGetFipsAlgorithmMode" bcrypt-get-fips-algorithm-mode :convention :stdcall) :int32
(pf-enabled :pointer)) ; BYTE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BCryptGetFipsAlgorithmMode = Win32::API::More->new('bcrypt',
'int BCryptGetFipsAlgorithmMode(LPVOID pfEnabled)');
# my $ret = $BCryptGetFipsAlgorithmMode->Call($pfEnabled);
# pfEnabled : BYTE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。