語言

DrbgParameters 類別

定義

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

[Android.Runtime.Register("java/security/DrbgParameters", ApiSince=35, DoNotGenerateAcw=true)]
public class DrbgParameters : Java.Lang.Object
[<Android.Runtime.Register("java/security/DrbgParameters", ApiSince=35, DoNotGenerateAcw=true)>]
type DrbgParameters = class
    inherit Object
繼承
DrbgParameters
屬性

備註

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

根據 NIST特別出版物800-90A修訂版1,《使用確定性隨機位元產生 器(800-90Ar1)隨機數生成建議》, <區塊引用> DRBG基於本建議中指定的DRBG機制,並包含隨機性來源。 DRBG 機制使用一種演算法(即 DRBG 演算法),該演算法從初始值產生一串位元,該初始值由從隨機性來源輸出中確定的種子決定。」 </區塊引用>

800-90Ar1 規範允許多種 DRBG 實作選擇,例如:ul<li 是熵源,li >< 是 DRBG 機制(例如 Hash_DRBG)、 >< li 是 DRBG 演算法(例如 SHA-256 用於 Hash_DRBG,AES-256 用於 CTR_DRBG。><>請注意,這並非我們以下稱為 SecureRandomSecureRandom#getInstance演算法</em> 所使用的<演算法,>並<具備包括預測抗性與重播支持在內的選用特性,>以及<最高>安全性。 </ul>

這些選擇是在每個實作中設定的,API 不會直接管理 SecureRandom 。 請查閱你的DRBG供應商文件,找出適合這種情況的實作方式。

另一方面,800-90Ar1規範確實有一些可配置選項,例如:ul<li 需要安全強度,><li 若需要預測抗性,>li< 個人化字串及額外輸入。><> </ul>

DRBG 實例可以以物件的參數 DrbgParameters.Instantiation 及其他資訊實例化(例如,nonce,該 nonce 不由此 API 管理)。 這與 NIST SP 800-90Ar1 中定義的標準對應 Instantiate_function 。

DRBG 實例可以重新植入物件的 DrbgParameters.Reseed 參數。 這與 NIST SP 800-90Ar1 中定義的標準對應 Reseed_function 。 呼叫 SecureRandom#reseed() 等同 SecureRandom#reseed(SecureRandomParameters) 於使用有效實例化的預測阻力旗標(由 SecureRandom#getParameters()返回)且不需額外輸入。

DRBG 實例會從 DrbgParameters.NextBytes 物件產生帶有額外參數的資料。 這與 NIST SP 800-90Ar1 中定義的標準對應 Generate_function 。 呼叫 SecureRandom#nextBytes(byte[]) 等 SecureRandom#nextBytes(byte[], SecureRandomParameters) 同於使用有效實例化的強度與預測阻力旗標(由 SecureRandom#getParameters()返回)且不需額外輸入。

DRBG 應該實作為 的 SecureRandomSpi子類別。 建議實作包含 1-arg 的 SecureRandomSpi#SecureRandomSpi(SecureRandomParameters) 建構子,該建構子會接收參數 DrbgParameters.Instantiation 。 若以此實作方式,任何 SecureRandom.getInstance() 方法皆可選擇此實作。 若由帶有參數SecureRandom.getInstance()的 選擇SecureRandomParameters,則該參數會傳入此建構子。 若由 a SecureRandom.getInstance() 選擇且無參數 SecureRandomParameters ,則以參數呼叫 null 建構子,實作應自行選擇參數。 它 SecureRandom#getParameters() 必須總是回傳一個非空有效 DrbgParameters.Instantiation 物件,反映 DRBG 實際實例化的方式。 呼叫者可利用這些資訊判斷物件 SecureRandom 是否為 DRBG 及其支援的功能。 請注意,回傳的值不一定等於 DrbgParameters.Instantiation 傳入 SecureRandom.getInstance() 呼叫的物件。 例如,請求的能力可以是, DrbgParameters.Capability#NONE 但實際值可以是 DrbgParameters.Capability#RESEED_ONLY 實作是否支援重種。 實作必須實作 SecureRandomSpi#engineNextBytes(byte[], SecureRandomParameters) 一個參數 DrbgParameters.NextBytes 的方法。 除非 的 SecureRandom#getParameters() 結果具有 DrbgParameters.Instantiation#getCapability() 能力 , Capability#NONE NONE否則必須實作 SecureRandomSpi#engineReseed(SecureRandomParameters) ,且該參數會取一個 DrbgParameters.Reseed 參數。

另一方面,若 DRBG 實作中沒有包含包含參數DrbgParameters.Instantiation的建構子(不建議),則只能由SecureRandom.getInstance()無SecureRandomParameters參數的方法選擇,若呼叫有getInstance參數的方法則不會被選擇SecureRandomParameters。 若以此實作,必須 SecureRandom#getParameters() 返回 null,且無需實作 SecureRandomSpi#engineNextBytes(byte[], SecureRandomParameters) 或 SecureRandomSpi#engineReseed(SecureRandomParameters)。

如果種子週期超過DRBG機制定義的最大種子壽命,DRBG可能會自動重新播種。

DRBG 實作應透過保留組態與有效參數來支援序列化與反序列化,但內部狀態不得序列化,且反序列化物件必須重新實例化。

範例: <blockquote>

SecureRandom drbg;
            byte[] buffer = new byte[32];

            // Any DRBG is OK
            drbg = SecureRandom.getInstance("DRBG");
            drbg.nextBytes(buffer);

            SecureRandomParameters params = drbg.getParameters();
            if (params instanceof DrbgParameters.Instantiation) {
                DrbgParameters.Instantiation ins = (DrbgParameters.Instantiation) params;
                if (ins.getCapability().supportsReseeding()) {
                    drbg.reseed();
                }
            }

            // The following call requests a weak DRBG instance. It is only
            // guaranteed to support 112 bits of security strength.
            drbg = SecureRandom.getInstance("DRBG",
                    DrbgParameters.instantiation(112, NONE, null));

            // Both the next two calls will likely fail, because drbg could be
            // instantiated with a smaller strength with no prediction resistance
            // support.
            drbg.nextBytes(buffer,
                    DrbgParameters.nextBytes(256, false, "more".getBytes()));
            drbg.nextBytes(buffer,
                    DrbgParameters.nextBytes(112, true, "more".getBytes()));

            // The following call requests a strong DRBG instance, with a
            // personalization string. If it successfully returns an instance,
            // that instance is guaranteed to support 256 bits of security strength
            // with prediction resistance available.
            drbg = SecureRandom.getInstance("DRBG", DrbgParameters.instantiation(
                    256, PR_AND_RESEED, "hello".getBytes()));

            // Prediction resistance is not requested in this single call,
            // but an additional input is used.
            drbg.nextBytes(buffer,
                    DrbgParameters.nextBytes(-1, false, "more".getBytes()));

            // Same for this call.
            drbg.reseed(DrbgParameters.reseed(false, "extra".getBytes()));

</區塊引用>

新增9。

Java 文件 java.security.DrbgParameters。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

建構函式

名稱 Description
DrbgParameters(IntPtr, JniHandleOwnership)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

屬性

名稱 Description
Class

回傳此 Object的執行時類別。

(繼承來源 Object)
Handle

底層 Android 實例的帳號。

(繼承來源 Object)
JniIdentityHashCode

取得由互通執行時指派給此 Java 對等端的身份雜湊碼。

(繼承來源 Object)
JniManagedPeerState

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
JniPeerMembers

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

PeerReference

取得這個 Java 節點的 JNI 物件參考。

(繼承來源 Object)
ThresholdClass

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

ThresholdType

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

方法

名稱 Description
Clone()

建立並回傳此物件的副本。

(繼承來源 Object)
Construct(JniObjectReference, JniObjectReferenceOptions)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
Dispose()

釋放該 Java 節點所持有的資源。

(繼承來源 Object)
Dispose(Boolean)

釋放該 Java 節點所持有的資源。

(繼承來源 Object)
DisposeUnlessReferenced()

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
Equals(Object)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
Equals(Object)

表示是否有其他物體「等同」於此物。

(繼承來源 Object)
GetHashCode()

回傳物件的雜湊碼值。

(繼承來源 Object)
InvokeInstantiation(Int32, DrbgParameters+Capability, Byte[])

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

InvokeNextBytes(Int32, Boolean, Byte[])

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

InvokeReseed(Boolean, Byte[])

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

JavaFinalize()
已淘汰.

當垃圾回收判定該物件不再有相關參考時,由垃圾回收器呼叫。

(繼承來源 Object)
Notify()

喚醒一個正在該物件監視器上等待的執行緒。

(繼承來源 Object)
NotifyAll()

喚醒所有等待該物件監視器的執行緒。

(繼承來源 Object)
SetHandle(IntPtr, JniHandleOwnership)

設定 Handle 屬性。

(繼承來源 Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
ToArray<T>()

從這個 Java 陣列包裝器建立一個受管理陣列。

(繼承來源 Object)
ToString()

回傳物件的字串表示。

(繼承來源 Object)
UnregisterFromRuntime()

將此 Java 節點從互通執行時中取消註冊。

(繼承來源 Object)
Wait()

導致目前執行緒等待被喚醒,通常是透過 <em>通知</><em 或 em>中斷</em> 來喚醒。

(繼承來源 Object)
Wait(Int64, Int32)

會讓目前執行緒等待喚醒,通常是透過 <em>通知</><em 或 em>中斷</em>,或是經過一定的真實時間。

(繼承來源 Object)
Wait(Int64)

會讓目前執行緒等待喚醒,通常是透過 <em>通知</><em 或 em>中斷</em>,或是經過一定的真實時間。

(繼承來源 Object)

明確介面實作

名稱 Description
IJavaPeerable.Disposed()

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
IJavaPeerable.Finalized()

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

(繼承來源 JavaObject)

擴充方法

名稱 Description
GetJniTypeName(IJavaPeerable)

取得實例 self類型的 JNI 名稱。

JavaAs<TResult>(IJavaPeerable)

試著強制self輸入 TResult,檢查 強制在 Java 端是否有效。

JavaCast<TResult>(IJavaObject)

執行 Android 執行時檢查型別轉換。

JavaCast<TResult>(IJavaObject)

此類別指定 DRBG(確定性隨機位元產生器)所使用的參數。

TryJavaCast<TResult>(IJavaPeerable, TResult)

試著強制self輸入 TResult,檢查 強制在 Java 端是否有效。

適用於