Sdílet prostřednictvím


KeyAgreement.GenerateSecret Method

Definition

Overloads

GenerateSecret()

Generates the shared secret and returns it in a new buffer.

GenerateSecret(String)

Creates the shared secret and returns it as a SecretKey object of the specified algorithm.

GenerateSecret(Byte[], Int32)

Generates the shared secret, and places it into the buffer sharedSecret, beginning at offset inclusive.

GenerateSecret()

Generates the shared secret and returns it in a new buffer.

[Android.Runtime.Register("generateSecret", "()[B", "")]
public byte[]? GenerateSecret ();
[<Android.Runtime.Register("generateSecret", "()[B", "")>]
member this.GenerateSecret : unit -> byte[]

Returns

Byte[]

the new buffer with the shared secret

Attributes

Exceptions

if this key agreement is not complete.

Remarks

Generates the shared secret and returns it in a new buffer.

This method resets this KeyAgreement object, so that it can be reused for further key agreements. Unless this key agreement is reinitialized with one of the init methods, the same private information and algorithm parameters will be used for subsequent key agreements.

Java documentation for javax.crypto.KeyAgreement.generateSecret().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

GenerateSecret(String)

Creates the shared secret and returns it as a SecretKey object of the specified algorithm.

[Android.Runtime.Register("generateSecret", "(Ljava/lang/String;)Ljavax/crypto/SecretKey;", "")]
public Javax.Crypto.ISecretKey? GenerateSecret (string? algorithm);
[<Android.Runtime.Register("generateSecret", "(Ljava/lang/String;)Ljavax/crypto/SecretKey;", "")>]
member this.GenerateSecret : string -> Javax.Crypto.ISecretKey

Parameters

algorithm
String

the requested secret-key algorithm

Returns

the shared secret key

Attributes

Exceptions

if this key agreement is not complete.

if the specified algorithm for the secret key does not exists.

if a SecretKey with the specified algorithm cannot be created using the generated shared secret.

Remarks

Creates the shared secret and returns it as a SecretKey object of the specified algorithm.

This method resets this KeyAgreement object, so that it can be reused for further key agreements. Unless this key agreement is reinitialized with one of the init methods, the same private information and algorithm parameters will be used for subsequent key agreements.

Java documentation for javax.crypto.KeyAgreement.generateSecret(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

GenerateSecret(Byte[], Int32)

Generates the shared secret, and places it into the buffer sharedSecret, beginning at offset inclusive.

[Android.Runtime.Register("generateSecret", "([BI)I", "")]
public int GenerateSecret (byte[]? sharedSecret, int offset);
[<Android.Runtime.Register("generateSecret", "([BI)I", "")>]
member this.GenerateSecret : byte[] * int -> int

Parameters

sharedSecret
Byte[]

the buffer for the shared secret

offset
Int32

the offset in sharedSecret where the shared secret will be stored

Returns

the number of bytes placed into sharedSecret

Attributes

Exceptions

if this key agreement is not complete.

if the specified buffer is too small for the shared secret.

Remarks

Generates the shared secret, and places it into the buffer sharedSecret, beginning at offset inclusive.

If the sharedSecret buffer is too small to hold the result, a ShortBufferException is thrown. In this case, this call should be repeated with a larger output buffer.

This method resets this KeyAgreement object, so that it can be reused for further key agreements. Unless this key agreement is reinitialized with one of the init methods, the same private information and algorithm parameters will be used for subsequent key agreements.

Java documentation for javax.crypto.KeyAgreement.generateSecret(byte[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to