Initialize the crypto backend.

    The backend can be one of two plugins:

        - 'x509' - Uses x509 certificates.
        - 'gpg' - Uses GnuPG keys.
492082
def init(**config):
    
    global _implementation
    global _validate_implementations

    if config.get('crypto_backend') == 'gpg':
        _implementation = gpg
    else:
        _implementation = x509

    _validate_implementations = []
    for mod in config.get('crypto_validate_backends', []):
        if mod == 'gpg':
            _validate_implementations.append(gpg)
        elif mod == 'x509':
            _validate_implementations.append(x509)
        else:
            raise ValueError("%r is not a valid crypto backend" % mod)

    if not _validate_implementations:
        _validate_implementations.append(_implementation)
238740
@Override
    public void initialize(String keyStoreName, String keyStorePath, String keyStoreType, String keyStoreProvider,
                           String keyStorePassword, String keyAlias) throws AuditSigningException {

        WsLocationAdmin locationAdmin = locationAdminRef.getService();
        if (locationAdmin != null) {
            serverName = locationAdmin.getServerName();
        }
        signerAlias = keyAlias;
        signerName = keyStoreName;
        signerKeyFileLocation = keyStorePath;

        crypto = new AuditCrypto();

        String JCEProvider = null;

        try {
            signature = Signature.getInstance(CRYPTO_ALGORITHM);

        } catch (Exception e) {
            Tr.error(tc, "security.audit.signing.init.error", new Object[] { e });
            throw new AuditSigningException(e.getMessage());
        }

        long begin_time = 0;
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Initializing audit signer at " + new java.util.Date(System.currentTimeMillis()));
        }

    }
439678
def load_signing_key(signing_key, crypto_backend=default_backend()):
    
    if not isinstance(crypto_backend, (Backend, MultiBackend)):
        raise ValueError('backend must be a valid Backend object')

    if isinstance(signing_key, EllipticCurvePrivateKey):
        return signing_key
    elif isinstance(signing_key, (str, unicode)):
        invalid_strings = [b'-----BEGIN PUBLIC KEY-----']
        invalid_string_matches = [
            string_value in signing_key
            for string_value in invalid_strings
        ]
        if any(invalid_string_matches):
            raise ValueError(
                'Signing key must be a private key, not a public key.')

        try:
            return load_der_private_key(
                signing_key, password=None, backend=crypto_backend)
        except:
            try:
                return load_pem_private_key(
                    signing_key, password=None, backend=crypto_backend)
            except Exception:
                raise ValueError(
                    'Signing key must be a valid private key PEM or DER.')
    else:
        raise ValueError('Signing key must be in string or unicode format.')
1016215
protected function _init()
    {
        if (!isset($this->_ob) ||
            ($this->_ob->md5 != hash('md5', $this->key))) {
            switch ($this->cipher) {
            case 'cbc':
                $this->_ob = new Horde_Crypt_Blowfish_Php_Cbc($this->key);
                break;

            case 'ecb':
                $this->_ob = new Horde_Crypt_Blowfish_Php_Ecb($this->key);
                break;
            }
        }
    }
775117
def process_pkcs7(self, data, name):
        
        from cryptography.hazmat.backends.openssl.backend import backend
        from cryptography.hazmat.backends.openssl.x509 import _Certificate

        # DER conversion
        is_pem = startswith(data, '-----')
        if self.re_match(r'^[a-zA-Z0-9-\s+=/]+$', data):
            is_pem = True

        try:
            der = data
            if is_pem:
                data = data.decode('utf8')
                data = re.sub(r'\s*-----\s*BEGIN\s+PKCS7\s*-----', '', data)
                data = re.sub(r'\s*-----\s*END\s+PKCS7\s*-----', '', data)
                der = base64.b64decode(data)

            bio = backend._bytes_to_bio(der)
            pkcs7 = backend._lib.d2i_PKCS7_bio(bio.bio, backend._ffi.NULL)
            backend.openssl_assert(pkcs7 != backend._ffi.NULL)
            signers = backend._lib.PKCS7_get0_signers(pkcs7, backend._ffi.NULL, 0)
            backend.openssl_assert(signers != backend._ffi.NULL)
            backend.openssl_assert(backend._lib.sk_X509_num(signers) > 0)
            x509_ptr = backend._lib.sk_X509_value(signers, 0)
            backend.openssl_assert(x509_ptr != backend._ffi.NULL)
            x509_ptr = backend._ffi.gc(x509_ptr, backend._lib.X509_free)
            x509 = _Certificate(backend, x509_ptr)

            self.num_pkcs7_cert += 1

            return [self.process_x509(x509, name=name, pem=False, source='pkcs7-cert', aux='')]

        except Exception as e:
            logger.debug('Error in PKCS7 processing %s: %s' % (name, e))
            self.trace_logger.log(e)
767502
def create_backend(name: str=None, git_index: GitIndex=None, args: str=None) -> StorageBackend:
    """"""
    if name is None:
        name = config.BACKEND
    if not args:
        args = config.BACKEND_ARGS
    if args:
        try:
            kwargs = dict(p.split("=") for p in args.split(","))
        except:  # flake8: noqa
            raise ValueError("Invalid args") from None
    else:
        kwargs = {}
    if git_index is None:
        git_index = GitIndex()
    kwargs["index"] = git_index
    return __registry__[name](**kwargs)
1219689
public function init()
    {
        // Check filepath
        if (empty($this->filepath)) {
            return;
        }

        // Get configurations
        $settings = include $this->filepath;

        // Check
        if (empty($settings)) {
            return;
        }

        // Update
        $this->configs = $settings;

        // Enable backend~frontend actions
        if (OL_ZEUS_ISADMIN) {
            // Backend
            add_action('init', [$this, 'addShortcodesBackend']);
        } else {
            // Frontend
            add_action('init', [$this, 'addShortcodesFrontend']);
        }
    }
333539
def initialize(self):
        """"""
        self._signing_key = SigningKey(os.urandom(32))
        self._auth_private = self._signing_key.to_seed()
        self._auth_public = self._signing_key.get_verifying_key().to_bytes()
        self._verify_private = curve25519.Private(secret=os.urandom(32))
        self._verify_public = self._verify_private.get_public()
        return self._auth_public, self._verify_public.serialize()
1330877
function init(pluginInterface) {
    const pi = pluginInterface;

    // Static contents call
    pi.http.endpoint('get', '*', (req, res, next) => {
        let path = req.path;
        if (path.charAt(path.length-1)=='/') path += 'index.html';

        const pt = pathm.join(pathm.dirname(__filename), 'htdocs', path);
        fs.readFile(pt, (err, data)=>{
            if (err) {
                res.status(404).send('No such resource');
                return;
            }
            if (path==='/js/customize.js') {
                data = data.toString();
                data = data.split('__%%RSA_PUB_KEY%%__')
                    .join('"'+pi.crypt.getPubKey()+'"');
            }
            res.set('Content-Type', mime.getType(path)); // 'text/html; charset=UTF-8'
            res.status(200);

            res.send(data);
        });
    });
}
1116200
protected void initialize() throws GeneralSecurityException {
		if(keyPair == null) {
			keyPair = createKeyPair();
		}
		keyAgreement.init(keyPair.getPrivate());
	}
53271
private void initialize() {
        createKeysIfNotExist();
        if (keyPair == null) {
            try {
                loadKeyPair();
            } catch (IOException | NoSuchAlgorithmException | InvalidKeySpecException e) {
                LOGGER.error("An error occurred loading key pair");
                LOGGER.error(e.getMessage());
            }
        }
        if (secretKey == null) {
            try {
                loadSecretKey();
            } catch (IOException | ClassNotFoundException e) {
                LOGGER.error("An error occurred loading secret key");
                LOGGER.error(e.getMessage());
            }
        }
    }
1143087
def authenticate
      begin
        @backend.transaction(true){
          raise NotInitializedError.new(@backend.path.path) unless @backend[:user] && @backend[:system] && @backend[:system][:created]
          check_salt!
        }
      rescue OpenSSL::Cipher::CipherError
        raise WrongMasterPasswordError
      end
    end
535246
def post_init(*args)
      logger.info "got connection from #{remote_ip}"

      # initialize the line-based protocol: IRC is \r\n
      @lt2_delimiter = "\r\n"

      # start up the IRCD for this connection
      @ircd = IRCD.new(self, options)

      if options[:ssl]
        logger.info "starting TLS for #{remote_ip}"
        start_tls(:cert_chain_file => options[:ssl_cert], :private_key_file => options[:ssl_private_key], :verify_peer => options[:ssl_verify_peer])
      end
    end
95058
def init(options, use_sigterm_handler=True):
    
    # pylint: disable-msg=W0613
    global _AUTH, _OPTIONS

    if isinstance(options, dict):
        _OPTIONS = DEFAULT_OPTIONS.copy()
        _OPTIONS.update(options)
    else:
        for optname, optvalue in DEFAULT_OPTIONS.iteritems():
            if hasattr(options, optname):
                _OPTIONS[optname] = getattr(options, optname)
            else:
                _OPTIONS[optname] = optvalue

    if _OPTIONS['testmethods']:
        def fortytwo(request):
            "test GET method"
            return 42
        def ping(request):
            "test POST method"
            return request.payload_params()
        register(fortytwo, 'GET')
        register(ping, 'POST')

    if _OPTIONS['auth_basic_file']:
        _AUTH = HttpAuthentication(_OPTIONS['auth_basic_file'],
                                   realm = _OPTIONS['auth_basic']).parse_file()

    for name, cmd in _COMMANDS.iteritems():
        if cmd.safe_init:
            LOG.info("safe_init: %r", name)
            cmd.safe_init(_OPTIONS)

    if use_sigterm_handler:
        # signal.signal(signal.SIGHUP, lambda *x: None) # XXX
        signal.signal(signal.SIGTERM, sigterm_handler)
        signal.signal(signal.SIGINT, sigterm_handler)
141690
@PostConstruct
    public synchronized void initialize() {
        final FwCoreDirection direction = assistCoreDirection();
        final SecurityResourceProvider provider = direction.assistSecurityResourceProvider();
        invertibleCryptographer = provider.providePrimaryInvertibleCryptographer();
        if (invertibleCryptographer == null) {
            String msg = "The provider returned null invertible cryptographer: " + provider;
            throw new FwRequiredAssistNotFoundException(msg);
        }
        oneWayCryptographer = provider.providePrimaryOneWayCryptographer();
        if (oneWayCryptographer == null) {
            String msg = "The provider returned null one-way cryptographer: " + provider;
            throw new FwRequiredAssistNotFoundException(msg);
        }
        showBootLogging();
    }
1116482
def x509(self):
        """"""
        if self._x509 is None:
            backend = default_backend()
            self._x509 = x509.load_pem_x509_certificate(force_bytes(self.pub), backend)
        return self._x509
977243
protected function initialize()
    {
        parent::initialize();
        $this->setSchemaDomainMapping(new Domain(PropelTypes::BOOLEAN, 'BOOLEAN'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::TINYINT, 'INT2'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::SMALLINT, 'INT2'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::BIGINT, 'INT8'));
        //$this->setSchemaDomainMapping(new Domain(PropelTypes::REAL, 'FLOAT'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, 'DOUBLE PRECISION'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::FLOAT, 'DOUBLE PRECISION'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, 'TEXT'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, 'BYTEA'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, 'BYTEA'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, 'BYTEA'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, 'BYTEA'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, 'TEXT'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, 'BYTEA'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, 'TEXT'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, 'INT2'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::SET, 'INT4'));
        $this->setSchemaDomainMapping(new Domain(PropelTypes::DECIMAL, 'NUMERIC'));
    }