File indexing completed on 2024-05-19 04:42:03

0001 #!/usr/bin/env python3
0002 # -*- coding: utf-8 -*-
0003 #
0004 # SPDX-FileCopyrightText: 2014 Denis Steckelmacher <steckdenis@yahoo.fr>
0005 #
0006 # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007 
0008 from jsgenerator import *
0009 from common import *
0010 
0011 # Print the license of the generated file (the same as the one of this file)
0012 license()
0013 basicTypes(globals())
0014 require('buffer')
0015 
0016 _object = 'new Object()'
0017 
0018 Module().members(
0019     F(_array, 'getCiphers'),
0020     F(_array, 'getHashes'),
0021     F(_object, 'createCredentials', ('details', _object)),
0022     F('new Hash()', 'createHash', ('algorithm', _string)),
0023     Class('Hash').members(
0024         F(_void, 'update', ('data', _string), ('input_encoding', _string)),
0025         F(_string, 'digest', ('encoding', _string))
0026     ),
0027     F('new Hmac()', 'createHmac', ('algorithm', _string), ('key', _string)),
0028     Class('Hmac').members(
0029         F(_void, 'update', ('data', _string)),
0030         F(_string, 'digest', ('encoding', _string))
0031     ),
0032     F('new Cipher()', 'createCipher', ('algorithm', _string), ('password', _string)),
0033     F('new Cipher()', 'createCipheriv', ('algorithm', _string), ('password', _string), ('iv', _string)),
0034     Class('Cipher').members(
0035         F(_void, 'update', ('data', _string), ('input_encoding', _string), ('output_encoding', _string)),
0036         F(_string, 'final', ('output_encoding', _string)),
0037         F(_void, 'setAutoPadding', ('auto_padding', _bool))
0038     ),
0039     F('new Decipher()', 'createDecipher', ('algorithm', _string), ('password', _string)),
0040     F('new Decipher()', 'createDecipheriv', ('algorithm', _string), ('password', _string), ('iv', _string)),
0041     Class('Decipher').members(
0042         F(_void, 'update', ('data', _string), ('input_encoding', _string), ('output_encoding', _string)),
0043         F(_string, 'final', ('output_encoding', _string)),
0044         F(_void, 'setAutoPadding', ('auto_padding', _bool))
0045     ),
0046     F('new Sign()', 'createSign', ('algorithm', _string)),
0047     Class('Sign').members(
0048         F(_void, 'update', ('data', _string)),
0049         F(_string, 'sign', ('private_key', _string), ('output_format', _string))
0050     ),
0051     F('new Verify()', 'createVerify', ('algorithm', _string)),
0052     Class('Verify').members(
0053         F(_void, 'update', ('data', _string)),
0054         F(_bool, 'verify', ('object', _string), ('signature', _string), ('signature_format', _string))
0055     ),
0056     F('new DiffieHellman()', 'createDiffieHellman', ('prime_length', _int)),
0057     Class('DiffieHellman').members(
0058         F(_string, 'generateKeys', ('encoding', _string)),
0059         F(_string, 'computeSecret', ('other_public_key', _string), ('input_encoding', _string), ('output_encoding', _string)),
0060         F(_string, 'getPrime', ('encoding', _string)),
0061         F(_string, 'getGenerator', ('encoding', _string)),
0062         F(_string, 'getPublicKey', ('encoding', _string)),
0063         F(_string, 'getPrivateKey', ('encoding', _string)),
0064         F(_void, 'setPublicKey', ('public_key', _string), ('encoding', _string)),
0065         F(_void, 'setPrivateKey', ('private_key', _string), ('encoding', _string)),
0066     ),
0067     F('new DiffieHellman()', 'getDiffieHellman', ('group_name', _string)),
0068     F(_void, 'pbkdf2', ('password', _string), ('salt', _string), ('iterations', _int), ('keylen', _int), ('callback', 'function(){}')),
0069     F(_string, 'pbkdf2Sync', ('password', _string), ('salt', _string), ('iterations', _int), ('keylen', _int)),
0070     F('new buffer.Buffer()', 'randomBytes', ('size', _int), ('callback', 'function(){}')),
0071     F('new buffer.Buffer()', 'pseudoRandomBytes', ('size', _int), ('callback', 'function(){}')),
0072     Var(_string, 'DEFAULT_ENCODING')
0073 ).print()