forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
55
Kha/Backends/Node/js/node/crypto/Certificate.hx
Normal file
55
Kha/Backends/Node/js/node/crypto/Certificate.hx
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import js.node.Buffer;
|
||||
|
||||
/**
|
||||
SPKAC is a Certificate Signing Request mechanism originally implemented by Netscape
|
||||
and now specified formally as part of HTML5's keygen element.
|
||||
**/
|
||||
@:jsRequire("crypto", "Certificate")
|
||||
extern class Certificate {
|
||||
function new();
|
||||
|
||||
/**
|
||||
Returns the challenge component in the form of a Node.js `Buffer`.
|
||||
|
||||
The `spkac` data structure includes a public key and a challenge.
|
||||
**/
|
||||
@:overload(function(spkac:String):Buffer {})
|
||||
function exportChallenge(spkac:Buffer):Buffer;
|
||||
|
||||
/**
|
||||
Returns the public key component in the form of a Node.js `Buffer`.
|
||||
|
||||
The `spkac` data structure includes a public key and a challenge.
|
||||
**/
|
||||
@:overload(function(spkac:String):Buffer {})
|
||||
function exportPublicKey(spkac:Buffer):Buffer;
|
||||
|
||||
/**
|
||||
Returns true if the given `spkac` data structure is valid, false otherwise.
|
||||
**/
|
||||
function verifySpkac(spkac:Buffer):Bool;
|
||||
}
|
84
Kha/Backends/Node/js/node/crypto/Cipher.hx
Normal file
84
Kha/Backends/Node/js/node/crypto/Cipher.hx
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import js.node.Buffer;
|
||||
|
||||
/**
|
||||
Class for encrypting data.
|
||||
|
||||
Returned by `Crypto.createCipher` and `Crypto.createCipheriv`.
|
||||
|
||||
Cipher objects are streams that are both readable and writable.
|
||||
The written plain text data is used to produce the encrypted data on the readable side.
|
||||
|
||||
The legacy `update` and `final` methods are also supported.
|
||||
**/
|
||||
extern class Cipher extends js.node.stream.Transform<Cipher> {
|
||||
/**
|
||||
Updates the cipher with `data`, the encoding of which is given in `input_encoding`
|
||||
and can be 'utf8', 'ascii' or 'binary'. If no encoding is provided, then a buffer is expected.
|
||||
If data is a Buffer then `input_encoding` is ignored.
|
||||
|
||||
The `output_encoding` specifies the output format of the enciphered data,
|
||||
and can be 'binary', 'base64' or 'hex'. If no encoding is provided, then a buffer is returned.
|
||||
|
||||
Returns the enciphered contents, and can be called many times with new data as it is streamed.
|
||||
**/
|
||||
@:overload(function(data:Buffer):Buffer {})
|
||||
@:overload(function(data:String, input_encoding:String):Buffer {})
|
||||
function update(data:String, input_encoding:String, output_encoding:String):String;
|
||||
|
||||
/**
|
||||
Returns any remaining enciphered contents, with `output_encoding` being one of: 'binary', 'base64' or 'hex'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
|
||||
Note: cipher object can not be used after `final` method has been called.
|
||||
**/
|
||||
@:native("final") @:overload(function():Buffer {})
|
||||
function finalContents(output_encoding:String):String;
|
||||
|
||||
/**
|
||||
You can disable automatic padding of the input data to block size.
|
||||
If `auto_padding` is false, the length of the entire input data
|
||||
must be a multiple of the cipher's block size or `final` will fail.
|
||||
|
||||
Useful for non-standard padding, e.g. using 0x0 instead of PKCS padding.
|
||||
You must call this before `final`.
|
||||
**/
|
||||
@:overload(function():Void {})
|
||||
function setAutoPadding(auto_padding:Bool):Void;
|
||||
|
||||
/**
|
||||
For authenticated encryption modes (currently supported: GCM), this method returns a `Buffer`
|
||||
that represents the authentication tag that has been computed from the given data.
|
||||
Should be called after encryption has been completed using the `final` method!
|
||||
**/
|
||||
function getAuthTag():Buffer;
|
||||
|
||||
/**
|
||||
For authenticated encryption modes (currently supported: GCM), this method sets the value
|
||||
used for the additional authenticated data (AAD) input parameter.
|
||||
**/
|
||||
function setAAD(buffer:Buffer):Void;
|
||||
}
|
83
Kha/Backends/Node/js/node/crypto/Decipher.hx
Normal file
83
Kha/Backends/Node/js/node/crypto/Decipher.hx
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import js.node.Buffer;
|
||||
|
||||
/**
|
||||
Class for decrypting data.
|
||||
|
||||
Returned by `Crypto.createDecipher` and `Crypto.createDecipheriv`.
|
||||
|
||||
Decipher objects are streams that are both readable and writable.
|
||||
The written enciphered data is used to produce the plain-text data on the the readable side.
|
||||
|
||||
The legacy `update` and `final` methods are also supported.
|
||||
**/
|
||||
extern class Decipher extends js.node.stream.Transform<Decipher> {
|
||||
/**
|
||||
Updates the decipher with `data`, which is encoded in 'binary', 'base64' or 'hex'.
|
||||
If no encoding is provided, then a buffer is expected.
|
||||
|
||||
The `output_decoding` specifies in what format to return the deciphered plaintext: 'binary', 'ascii' or 'utf8'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
**/
|
||||
@:overload(function(data:Buffer):Buffer {})
|
||||
@:overload(function(data:String, input_encoding:String):Buffer {})
|
||||
function update(data:String, input_encoding:String, output_encoding:String):String;
|
||||
|
||||
/**
|
||||
Returns any remaining plaintext which is deciphered,
|
||||
with `output_encoding` being one of: 'binary', 'ascii' or 'utf8'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
|
||||
Note: decipher object can not be used after `final` method has been called.
|
||||
**/
|
||||
@:native("final") @:overload(function():Buffer {})
|
||||
function finalContents(output_encoding:String):String;
|
||||
|
||||
/**
|
||||
You can disable auto padding if the data has been encrypted without standard block padding
|
||||
to prevent `final` from checking and removing it.
|
||||
|
||||
Can only work if the input data's length is a multiple of the ciphers block size.
|
||||
|
||||
You must call this before streaming data to `update`.
|
||||
**/
|
||||
@:overload(function():Void {})
|
||||
function setAutoPadding(auto_padding:Bool):Void;
|
||||
|
||||
/**
|
||||
For authenticated encryption modes (currently supported: GCM), this method must be used
|
||||
to pass in the received authentication tag. If no tag is provided or if the ciphertext
|
||||
has been tampered with, `final` will throw, thus indicating that the ciphertext should be
|
||||
discarded due to failed authentication.
|
||||
**/
|
||||
function setAuthTag(buffer:Buffer):Void;
|
||||
|
||||
/**
|
||||
For authenticated encryption modes (currently supported: GCM), this method sets the value
|
||||
used for the additional authenticated data (AAD) input parameter.
|
||||
**/
|
||||
function setAAD(buffer:Buffer):Void;
|
||||
}
|
121
Kha/Backends/Node/js/node/crypto/DiffieHellman.hx
Normal file
121
Kha/Backends/Node/js/node/crypto/DiffieHellman.hx
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import js.node.Buffer;
|
||||
|
||||
/**
|
||||
Common interface for `DiffieHellman` and a mimic object returned by `Crypto.getDiffieHellman`.
|
||||
See `DiffieHellman` documentation.
|
||||
**/
|
||||
@:remove
|
||||
extern interface IDiffieHellman {
|
||||
@:overload(function():Buffer {})
|
||||
function generateKeys(encoding:String):String;
|
||||
|
||||
@:overload(function(other_public_key:Buffer):Buffer {})
|
||||
@:overload(function(other_public_key:String, input_encoding:String):Buffer {})
|
||||
function computeSecret(other_public_key:String, input_encoding:String, output_encoding:String):String;
|
||||
|
||||
@:overload(function():Buffer {})
|
||||
function getPrime(encoding:String):String;
|
||||
|
||||
@:overload(function():Buffer {})
|
||||
function getGenerator(encoding:String):String;
|
||||
|
||||
@:overload(function():Buffer {})
|
||||
function getPublicKey(encoding:String):String;
|
||||
|
||||
@:overload(function():Buffer {})
|
||||
function getPrivateKey(encoding:String):String;
|
||||
}
|
||||
|
||||
/**
|
||||
The class for creating Diffie-Hellman key exchanges.
|
||||
Returned by `Crypto.createDiffieHellman`.
|
||||
**/
|
||||
extern class DiffieHellman implements IDiffieHellman {
|
||||
/**
|
||||
Generates private and public Diffie-Hellman key values, and returns the public key in the specified `encoding`.
|
||||
This key should be transferred to the other party. `encoding` can be 'binary', 'hex', or 'base64'.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function generateKeys(encoding:String):String;
|
||||
|
||||
/**
|
||||
Computes the shared secret using `other_public_key` as the other party's public key
|
||||
and returns the computed shared secret.
|
||||
|
||||
Supplied key is interpreted using specified `input_encoding`,
|
||||
and secret is encoded using specified `output_encoding`.
|
||||
|
||||
Encodings can be 'binary', 'hex', or 'base64'.
|
||||
|
||||
If the input encoding is not provided, then a buffer is expected.
|
||||
**/
|
||||
@:overload(function(other_public_key:Buffer):Buffer {})
|
||||
@:overload(function(other_public_key:String, input_encoding:String):Buffer {})
|
||||
function computeSecret(other_public_key:String, input_encoding:String, output_encoding:String):String;
|
||||
|
||||
/**
|
||||
Returns the Diffie-Hellman prime in the specified encoding, which can be 'binary', 'hex', or 'base64'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function getPrime(encoding:String):String;
|
||||
|
||||
/**
|
||||
Returns the Diffie-Hellman generator in the specified encoding, which can be 'binary', 'hex', or 'base64'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function getGenerator(encoding:String):String;
|
||||
|
||||
/**
|
||||
Returns the Diffie-Hellman public key in the specified encoding, which can be 'binary', 'hex', or 'base64'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function getPublicKey(encoding:String):String;
|
||||
|
||||
/**
|
||||
Returns the Diffie-Hellman private key in the specified encoding, which can be 'binary', 'hex', or 'base64'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function getPrivateKey(encoding:String):String;
|
||||
|
||||
/**
|
||||
Sets the Diffie-Hellman public key. Key encoding can be 'binary', 'hex' or 'base64'.
|
||||
If no `encoding` is provided, then a `Buffer` is expected.
|
||||
**/
|
||||
@:overload(function(public_key:Buffer):Void {})
|
||||
function setPublicKey(public_key:String, encoding:String):Void;
|
||||
|
||||
/**
|
||||
Sets the Diffie-Hellman private key. Key encoding can be 'binary', 'hex' or 'base64'.
|
||||
If no `encoding` is provided, then a `Buffer` is expected.
|
||||
**/
|
||||
@:overload(function(private_key:Buffer):Void {})
|
||||
function setPrivateKey(private_key:String, encoding:String):Void;
|
||||
}
|
99
Kha/Backends/Node/js/node/crypto/ECDH.hx
Normal file
99
Kha/Backends/Node/js/node/crypto/ECDH.hx
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import haxe.extern.EitherType;
|
||||
import js.node.Buffer;
|
||||
|
||||
@:enum abstract ECDHFormat(String) from String to String {
|
||||
var Compressed = "compressed";
|
||||
var Uncompressed = "uncompressed";
|
||||
var Hybrid = "hybrid";
|
||||
}
|
||||
|
||||
/**
|
||||
The class for creating EC Diffie-Hellman key exchanges.
|
||||
|
||||
Returned by `Crypto.createECDH`.
|
||||
**/
|
||||
extern class ECDH {
|
||||
/**
|
||||
Generates private and public EC Diffie-Hellman key values, and returns the public key
|
||||
in the specified `format` and `encoding`. This key should be transferred to the other party.
|
||||
|
||||
Format specifies point encoding and can be 'compressed', 'uncompressed', or 'hybrid'.
|
||||
If no format is provided - the point will be returned in 'uncompressed' format.
|
||||
|
||||
Encoding can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.
|
||||
**/
|
||||
function generateKeys(?encoding:String, ?format:ECDHFormat):EitherType<String, Buffer>;
|
||||
|
||||
/**
|
||||
Computes the shared secret using `other_public_key` as the other party's public key
|
||||
and returns the computed shared secret. Supplied key is interpreted using specified `input_encoding`,
|
||||
and secret is encoded using specified `output_encoding`.
|
||||
|
||||
Encodings can be 'binary', 'hex', or 'base64'.
|
||||
|
||||
If the input encoding is not provided, then a buffer is expected.
|
||||
If no output encoding is given, then a buffer is returned.
|
||||
**/
|
||||
@:overload(function(other_public_key:String, input_encoding:String, output_encoding:String):String {})
|
||||
@:overload(function(other_public_key:String, input_encoding:String):Buffer {})
|
||||
function computeSecret(other_public_key:Buffer):Buffer;
|
||||
|
||||
/**
|
||||
Returns the EC Diffie-Hellman public key in the specified `encoding` and `format`.
|
||||
|
||||
Format specifies point encoding and can be 'compressed', 'uncompressed', or 'hybrid'.
|
||||
If no format is provided - the point will be returned in 'uncompressed' format.
|
||||
|
||||
Encoding can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.
|
||||
**/
|
||||
function getPublicKey(?encoding:String, ?format:ECDHFormat):EitherType<String, Buffer>;
|
||||
|
||||
/**
|
||||
Returns the EC Diffie-Hellman private key in the specified encoding, which can be 'binary', 'hex', or 'base64'.
|
||||
If no `encoding` is provided, then a buffer is returned.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function getPrivateKey(encoding:String):String;
|
||||
|
||||
/**
|
||||
Sets the EC Diffie-Hellman public key.
|
||||
|
||||
Key encoding can be 'binary', 'hex' or 'base64'.
|
||||
If no encoding is provided, then a buffer is expected.
|
||||
**/
|
||||
@:overload(function(public_key:Buffer):Void {})
|
||||
function setPublicKey(public_key:String, encoding:String):Void;
|
||||
|
||||
/**
|
||||
Sets the EC Diffie-Hellman private key.
|
||||
|
||||
Key encoding can be 'binary', 'hex' or 'base64'.
|
||||
If no encoding is provided, then a buffer is expected.
|
||||
**/
|
||||
@:overload(function(private_key:Buffer):Void {})
|
||||
function setPrivateKey(private_key:String, encoding:String):Void;
|
||||
}
|
60
Kha/Backends/Node/js/node/crypto/Hash.hx
Normal file
60
Kha/Backends/Node/js/node/crypto/Hash.hx
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import js.node.Buffer;
|
||||
|
||||
/**
|
||||
The class for creating hash digests of data.
|
||||
|
||||
It is a stream that is both readable and writable.
|
||||
The written data is used to compute the hash.
|
||||
Once the writable side of the stream is ended, use the `read` method to get the computed hash digest.
|
||||
|
||||
The legacy `update` and `digest` methods are also supported.
|
||||
|
||||
Returned by `Crypto.createHash`.
|
||||
**/
|
||||
extern class Hash extends js.node.stream.Transform<Hash> {
|
||||
/**
|
||||
Updates the hash content with the given `data`,
|
||||
|
||||
the `encoding` of which is given in `input_encoding` and can be 'utf8', 'ascii' or 'binary'.
|
||||
If no `encoding` is provided and the input is a string an encoding of 'binary' is enforced.
|
||||
If `data` is a `Buffer` then `input_encoding` is ignored.
|
||||
|
||||
This can be called many times with new data as it is streamed.
|
||||
**/
|
||||
@:overload(function(data:Buffer):Hash {})
|
||||
function update(data:String, ?input_encoding:String):Hash;
|
||||
|
||||
/**
|
||||
Calculates the digest of all of the passed data to be hashed.
|
||||
The `encoding` can be 'hex', 'binary' or 'base64'.
|
||||
If no `encoding` is provided, then a buffer is returned.
|
||||
|
||||
Note: hash object can not be used after `digest` method has been called.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function digest(encoding:String):String;
|
||||
}
|
55
Kha/Backends/Node/js/node/crypto/Hmac.hx
Normal file
55
Kha/Backends/Node/js/node/crypto/Hmac.hx
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import js.node.Buffer;
|
||||
|
||||
/**
|
||||
Class for creating cryptographic hmac content.
|
||||
|
||||
It is a stream that is both readable and writable. The written data is used to compute the hmac.
|
||||
Once the writable side of the stream is ended, use the `read` method to get the computed digest.
|
||||
|
||||
The legacy `update` and `digest` methods are also supported.
|
||||
|
||||
Returned by `Crypto.createHmac`.
|
||||
**/
|
||||
extern class Hmac extends js.node.stream.Transform<Hmac> {
|
||||
/**
|
||||
Update the hmac content with the given data.
|
||||
|
||||
This can be called many times with new data as it is streamed.
|
||||
**/
|
||||
@:overload(function(data:Buffer):Hmac {})
|
||||
function update(data:String, ?input_encoding:String):Hmac;
|
||||
|
||||
/**
|
||||
Calculates the digest of all of the passed data to the hmac.
|
||||
The `encoding` can be 'hex', 'binary' or 'base64'.
|
||||
If no `encoding` is provided, then a buffer is returned.
|
||||
|
||||
Note: hmac object can not be used after `digest` method has been called.
|
||||
**/
|
||||
@:overload(function():Buffer {})
|
||||
function digest(encoding:String):String;
|
||||
}
|
57
Kha/Backends/Node/js/node/crypto/Sign.hx
Normal file
57
Kha/Backends/Node/js/node/crypto/Sign.hx
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import haxe.extern.EitherType;
|
||||
import js.node.Buffer;
|
||||
import js.node.stream.Writable;
|
||||
|
||||
/**
|
||||
Class for generating signatures.
|
||||
|
||||
Returned by `Crypto.createSign`.
|
||||
|
||||
Sign objects are writable streams. The written data is used to generate the signature.
|
||||
Once all of the data has been written, the sign method will return the signature.
|
||||
|
||||
The legacy `update` method is also supported.
|
||||
**/
|
||||
extern class Sign extends Writable<Sign> {
|
||||
/**
|
||||
Updates the sign object with data.
|
||||
This can be called many times with new data as it is streamed.
|
||||
**/
|
||||
@:overload(function(data:Buffer):Void {})
|
||||
function update(data:String, ?encoding:String):Void;
|
||||
|
||||
/**
|
||||
Calculates the signature on all the updated data passed through the sign.
|
||||
`private_key` is a string containing the PEM encoded private key for signing.
|
||||
Returns the signature in `output_format` which can be 'binary', 'hex' or 'base64'.
|
||||
If no encoding is provided, then a buffer is returned.
|
||||
|
||||
Note: sign object can not be used after `sign` method has been called.
|
||||
**/
|
||||
@:overload(function(private_key:EitherType<String, {key:String, passphrase:String}>):Buffer {})
|
||||
function sign(private_key:EitherType<String, {key:String, passphrase:String}>, output_format:String):String;
|
||||
}
|
60
Kha/Backends/Node/js/node/crypto/Verify.hx
Normal file
60
Kha/Backends/Node/js/node/crypto/Verify.hx
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C)2014-2020 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package js.node.crypto;
|
||||
|
||||
import js.node.Buffer;
|
||||
import js.node.stream.Writable;
|
||||
|
||||
/**
|
||||
Class for verifying signatures.
|
||||
Returned by `Crypto.createVerify`.
|
||||
|
||||
Verify objects are writable streams. The written data is used to validate against the supplied signature.
|
||||
Once all of the data has been written, the verify method will return true if the supplied signature is valid.
|
||||
|
||||
The legacy `update` method is also supported.
|
||||
**/
|
||||
extern class Verify extends Writable<Sign> {
|
||||
/**
|
||||
Updates the verifier object with data. This can be called many times with new data as it is streamed.
|
||||
**/
|
||||
@:overload(function(data:Buffer):Void {})
|
||||
function update(data:String, ?encoding:String):Void;
|
||||
|
||||
/**
|
||||
Verifies the signed data by using the object and signature.
|
||||
|
||||
`object` is a string containing a PEM encoded object, which can be one of RSA public key,
|
||||
DSA public key, or X.509 certificate.
|
||||
|
||||
`signature` is the previously calculated signature for the data,
|
||||
in the `signature_format` which can be 'binary', 'hex' or 'base64'.
|
||||
If no encoding is specified, then a buffer is expected.
|
||||
|
||||
Returns true or false depending on the validity of the signature for the data and public key.
|
||||
|
||||
Note: verifier object can not be used after `verify` method has been called.
|
||||
**/
|
||||
@:overload(function(object:String, signature:Buffer):Bool {})
|
||||
function verify(object:String, signature:String, signature_format:String):Bool;
|
||||
}
|
Reference in New Issue
Block a user