[][src]Struct gdnative::api::Crypto

pub struct Crypto { /* fields omitted */ }

core class Crypto inherits Reference (reference counted).

Official documentation

See the documentation of this class in the Godot engine's official documentation.

Memory management

The lifetime of this object is automatically managed through reference counting.

Class hierarchy

Crypto inherits methods from:

Safety

All types in the Godot API have "interior mutability" in Rust parlance. To enforce that the official thread-safety guidelines are followed, the typestate pattern is used in the Ref and TRef smart pointers, and the Instance API. The typestate Access in these types tracks whether the access is unique, shared, or exclusive to the current thread. For more information, see the type-level documentation on Ref.

Implementations

impl Crypto[src]

pub fn new() -> Ref<Crypto, Unique>[src]

Creates a new instance of this object.

This is a reference-counted type. The returned object is automatically managed by Ref.

pub fn generate_random_bytes(&self, size: i64) -> TypedArray<u8>[src]

Generates a [PoolByteArray] of cryptographically secure random bytes with given [code]size[/code].

pub fn generate_rsa(&self, size: i64) -> Option<Ref<CryptoKey, Shared>>[src]

Generates an RSA [CryptoKey] that can be used for creating self-signed certificates and passed to [method StreamPeerSSL.accept_stream].

pub fn generate_self_signed_certificate(
    &self,
    key: impl AsArg<CryptoKey>,
    issuer_name: impl Into<GodotString>,
    not_before: impl Into<GodotString>,
    not_after: impl Into<GodotString>
) -> Option<Ref<X509Certificate, Shared>>
[src]

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.
				[codeblock]
				var crypto = Crypto.new()
				# Generate 4096 bits RSA key.
				var key = crypto.generate_rsa(4096)
				# Generate self-signed certificate using the given key.
				var cert = crypto.generate_self_signed_certificate(key, "CN=example.com,O=A Game Company,C=IT")
				[/codeblock]

Default Arguments

  • issuer_name - "CN=myserver,O=myorganisation,C=IT"
  • not_before - "20140101000000"
  • not_after - "20340101000000"

Methods from Deref<Target = Reference>

pub fn init_ref(&self) -> bool[src]

Initializes the internal reference counter. Use this only if you really know what you are doing.
				Returns whether the initialization was successful.

Trait Implementations

impl Debug for Crypto[src]

impl Deref for Crypto[src]

type Target = Reference

The resulting type after dereferencing.

impl DerefMut for Crypto[src]

impl GodotObject for Crypto[src]

type RefKind = RefCounted

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

impl Instanciable for Crypto[src]

impl SubClass<Object> for Crypto[src]

impl SubClass<Reference> for Crypto[src]

Auto Trait Implementations

impl RefUnwindSafe for Crypto

impl !Send for Crypto

impl !Sync for Crypto

impl Unpin for Crypto

impl UnwindSafe for Crypto

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.