diff options
Diffstat (limited to 'doc/classes/Crypto.xml')
-rw-r--r-- | doc/classes/Crypto.xml | 93 |
1 files changed, 44 insertions, 49 deletions
diff --git a/doc/classes/Crypto.xml b/doc/classes/Crypto.xml index b3bbbae94f..3d7ca956da 100644 --- a/doc/classes/Crypto.xml +++ b/doc/classes/Crypto.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Crypto" inherits="Reference" version="4.0"> +<class name="Crypto" inherits="RefCounted" version="4.0"> <brief_description> Access to advanced cryptographic functionalities. </brief_description> @@ -73,59 +73,53 @@ <tutorials> </tutorials> <methods> + <method name="constant_time_compare"> + <return type="bool" /> + <argument index="0" name="trusted" type="PackedByteArray" /> + <argument index="1" name="received" type="PackedByteArray" /> + <description> + Compares two [PackedByteArray]s for equality without leaking timing information in order to prevent timing attacks. + See [url=https://paragonie.com/blog/2015/11/preventing-timing-attacks-on-string-comparison-with-double-hmac-strategy]this blog post[/url] for more information. + </description> + </method> <method name="decrypt"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <argument index="1" name="ciphertext" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="ciphertext" type="PackedByteArray" /> <description> Decrypt the given [code]ciphertext[/code] with the provided private [code]key[/code]. [b]Note[/b]: The maximum size of accepted ciphertext is limited by the key size. </description> </method> <method name="encrypt"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <argument index="1" name="plaintext" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="plaintext" type="PackedByteArray" /> <description> Encrypt the given [code]plaintext[/code] with the provided public [code]key[/code]. [b]Note[/b]: The maximum size of accepted plaintext is limited by the key size. </description> </method> <method name="generate_random_bytes"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="size" type="int" /> <description> Generates a [PackedByteArray] of cryptographically secure random bytes with given [code]size[/code]. </description> </method> <method name="generate_rsa"> - <return type="CryptoKey"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="CryptoKey" /> + <argument index="0" name="size" type="int" /> <description> Generates an RSA [CryptoKey] that can be used for creating self-signed certificates and passed to [method StreamPeerSSL.accept_stream]. </description> </method> <method name="generate_self_signed_certificate"> - <return type="X509Certificate"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <argument index="1" name="issuer_name" type="String" default=""CN=myserver,O=myorganisation,C=IT""> - </argument> - <argument index="2" name="not_before" type="String" default=""20140101000000""> - </argument> - <argument index="3" name="not_after" type="String" default=""20340101000000""> - </argument> + <return type="X509Certificate" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="issuer_name" type="String" default=""CN=myserver,O=myorganisation,C=IT"" /> + <argument index="2" name="not_before" type="String" default=""20140101000000"" /> + <argument index="3" name="not_after" type="String" default=""20340101000000"" /> <description> Generates a self-signed [X509Certificate] from the given [CryptoKey] and [code]issuer_name[/code]. The certificate validity will be defined by [code]not_before[/code] and [code]not_after[/code] (first valid date and last valid date). The [code]issuer_name[/code] must contain at least "CN=" (common name, i.e. the domain name), "O=" (organization, i.e. your company name), "C=" (country, i.e. 2 lettered ISO-3166 code of the country the organization is based in). A small example to generate an RSA key and a X509 self-signed certificate. @@ -147,30 +141,31 @@ [/codeblocks] </description> </method> + <method name="hmac_digest"> + <return type="PackedByteArray" /> + <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType" /> + <argument index="1" name="key" type="PackedByteArray" /> + <argument index="2" name="msg" type="PackedByteArray" /> + <description> + Generates an [url=https://en.wikipedia.org/wiki/HMAC]HMAC[/url] digest of [code]msg[/code] using [code]key[/code]. The [code]hash_type[/code] parameter is the hashing algorithm that is used for the inner and outer hashes. + Currently, only [constant HashingContext.HASH_SHA256] and [constant HashingContext.HASH_SHA1] are supported. + </description> + </method> <method name="sign"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType"> - </argument> - <argument index="1" name="hash" type="PackedByteArray"> - </argument> - <argument index="2" name="key" type="CryptoKey"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType" /> + <argument index="1" name="hash" type="PackedByteArray" /> + <argument index="2" name="key" type="CryptoKey" /> <description> Sign a given [code]hash[/code] of type [code]hash_type[/code] with the provided private [code]key[/code]. </description> </method> <method name="verify"> - <return type="bool"> - </return> - <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType"> - </argument> - <argument index="1" name="hash" type="PackedByteArray"> - </argument> - <argument index="2" name="signature" type="PackedByteArray"> - </argument> - <argument index="3" name="key" type="CryptoKey"> - </argument> + <return type="bool" /> + <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType" /> + <argument index="1" name="hash" type="PackedByteArray" /> + <argument index="2" name="signature" type="PackedByteArray" /> + <argument index="3" name="key" type="CryptoKey" /> <description> Verify that a given [code]signature[/code] for [code]hash[/code] of type [code]hash_type[/code] against the provided public [code]key[/code]. </description> |