{"id":13399158,"url":"https://github.com/openssl/openssl","last_synced_at":"2025-05-12T16:21:51.998Z","repository":{"id":37276088,"uuid":"7634677","full_name":"openssl/openssl","owner":"openssl","description":"TLS/SSL and crypto library","archived":false,"fork":false,"pushed_at":"2025-05-05T06:27:11.000Z","size":285444,"stargazers_count":27298,"open_issues_count":1985,"forks_count":10521,"subscribers_count":1028,"default_branch":"master","last_synced_at":"2025-05-05T11:47:20.048Z","etag":null,"topics":["cryptography","decryption","encryption","openssl","ssl","tls"],"latest_commit_sha":null,"homepage":"https://www.openssl.org","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openssl.png","metadata":{"files":{"readme":"README-ENGINES.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"SUPPORT.md","governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":"https://openssl-foundation.org/sponsorship/"}},"created_at":"2013-01-15T22:34:48.000Z","updated_at":"2025-05-05T08:00:09.000Z","dependencies_parsed_at":"2023-09-26T00:51:57.444Z","dependency_job_id":"f916fb1a-0cad-4c34-a6b2-19eb7da99884","html_url":"https://github.com/openssl/openssl","commit_stats":null,"previous_names":[],"tags_count":393,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openssl%2Fopenssl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openssl%2Fopenssl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openssl%2Fopenssl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openssl%2Fopenssl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openssl","download_url":"https://codeload.github.com/openssl/openssl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252504146,"owners_count":21758654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","decryption","encryption","openssl","ssl","tls"],"created_at":"2024-07-30T19:00:34.741Z","updated_at":"2025-05-05T12:53:38.840Z","avatar_url":"https://github.com/openssl.png","language":"C","readme":"Engines\n=======\n\nDeprecation Note\n----------------\n\nThe ENGINE API was introduced in OpenSSL version 0.9.6 as a low level\ninterface for adding alternative implementations of cryptographic\nprimitives, most notably for integrating hardware crypto devices.\n\nThe ENGINE interface has its limitations and it has been superseded\nby the [PROVIDER API](README-PROVIDERS.md), it is deprecated in OpenSSL\nversion 3.0. The following documentation is retained as an aid for\nusers who need to maintain or support existing ENGINE implementations.\nSupport for new hardware devices or new algorithms should be added\nvia providers, and existing engines should be converted to providers\nas soon as possible.\n\nBuilt-in ENGINE implementations\n-------------------------------\n\nThere are currently built-in ENGINE implementations for the following\ncrypto devices:\n\n- Microsoft CryptoAPI\n- VIA Padlock\n- nCipher CHIL\n\nIn addition, dynamic binding to external ENGINE implementations is now\nprovided by a special ENGINE called \"dynamic\". See the \"DYNAMIC ENGINE\"\nsection below for details.\n\nAt this stage, a number of things are still needed and are being worked on:\n\n1. Integration of EVP support.\n2. Configuration support.\n3. Documentation!\n\nIntegration of EVP support\n--------------------------\n\nWith respect to EVP, this relates to support for ciphers and digests in\nthe ENGINE model so that alternative implementations of existing\nalgorithms/modes (or previously unimplemented ones) can be provided by\nENGINE implementations.\n\nConfiguration support\n---------------------\n\nConfiguration support currently exists in the ENGINE API itself, in the\nform of \"control commands\". These allow an application to expose to the\nuser/admin the set of commands and parameter types a given ENGINE\nimplementation supports, and for an application to directly feed string\nbased input to those ENGINEs, in the form of name-value pairs. This is an\nextensible way for ENGINEs to define their own \"configuration\" mechanisms\nthat are specific to a given ENGINE (eg. for a particular hardware\ndevice) but that should be consistent across *all* OpenSSL-based\napplications when they use that ENGINE. Work is in progress (or at least\nin planning) for supporting these control commands from the CONF (or\nNCONF) code so that applications using OpenSSL's existing configuration\nfile format can have ENGINE settings specified in much the same way.\nPresently however, applications must use the ENGINE API itself to provide\nsuch functionality. To see first hand the types of commands available\nwith the various compiled-in ENGINEs (see further down for dynamic\nENGINEs), use the \"engine\" openssl utility with full verbosity, i.e.:\n\n    openssl engine -vvvv\n\nDocumentation\n-------------\n\nDocumentation? Volunteers welcome! The source code is reasonably well\nself-documenting, but some summaries and usage instructions are needed -\nmoreover, they are needed in the same POD format the existing OpenSSL\ndocumentation is provided in. Any complete or incomplete contributions\nwould help make this happen.\n\nSTABILITY \u0026 BUG-REPORTS\n=======================\n\nWhat already exists is fairly stable as far as it has been tested, but\nthe test base has been a bit small most of the time. For the most part,\nthe vendors of the devices these ENGINEs support have contributed to the\ndevelopment and/or testing of the implementations, and *usually* (with no\nguarantees) have experience in using the ENGINE support to drive their\ndevices from common OpenSSL-based applications. Bugs and/or inexplicable\nbehaviour in using a specific ENGINE implementation should be sent to the\nauthor of that implementation (if it is mentioned in the corresponding C\nfile), and in the case of implementations for commercial hardware\ndevices, also through whatever vendor support channels are available. If\nnone of this is possible, or the problem seems to be something about the\nENGINE API itself (ie. not necessarily specific to a particular ENGINE\nimplementation) then you should mail complete details to the relevant\nOpenSSL mailing list. For a definition of \"complete details\", refer to\nthe OpenSSL \"README\" file. As for which list to send it to:\n\n- openssl-users: if you are *using* the ENGINE abstraction, either in an\n  pre-compiled application or in your own application code.\n\n- openssl-dev: if you are discussing problems with OpenSSL source code.\n\nUSAGE\n=====\n\nThe default \"openssl\" ENGINE is always chosen when performing crypto\noperations unless you specify otherwise. You must actively tell the\nopenssl utility commands to use anything else through a new command line\nswitch called \"-engine\". Also, if you want to use the ENGINE support in\nyour own code to do something similar, you must likewise explicitly\nselect the ENGINE implementation you want.\n\nDepending on the type of hardware, system, and configuration, \"settings\"\nmay need to be applied to an ENGINE for it to function as expected/hoped.\nThe recommended way of doing this is for the application to support\nENGINE \"control commands\" so that each ENGINE implementation can provide\nwhatever configuration primitives it might require and the application\ncan allow the user/admin (and thus the hardware vendor's support desk\nalso) to provide any such input directly to the ENGINE implementation.\nThis way, applications do not need to know anything specific to any\ndevice, they only need to provide the means to carry such user/admin\ninput through to the ENGINE in question. Ie. this connects *you* (and\nyour helpdesk) to the specific ENGINE implementation (and device), and\nallows application authors to not get buried in hassle supporting\narbitrary devices they know (and care) nothing about.\n\nA new \"openssl\" utility, \"openssl engine\", has been added in that allows\nfor testing and examination of ENGINE implementations. Basic usage\ninstructions are available by specifying the \"-?\" command line switch.\n\nDYNAMIC ENGINES\n===============\n\nThe new \"dynamic\" ENGINE provides a low-overhead way to support ENGINE\nimplementations that aren't pre-compiled and linked into OpenSSL-based\napplications. This could be because existing compiled-in implementations\nhave known problems and you wish to use a newer version with an existing\napplication. It could equally be because the application (or OpenSSL\nlibrary) you are using simply doesn't have support for the ENGINE you\nwish to use, and the ENGINE provider (eg. hardware vendor) is providing\nyou with a self-contained implementation in the form of a shared-library.\nThe other use-case for \"dynamic\" is with applications that wish to\nmaintain the smallest foot-print possible and so do not link in various\nENGINE implementations from OpenSSL, but instead leaves you to provide\nthem, if you want them, in the form of \"dynamic\"-loadable\nshared-libraries. It should be possible for hardware vendors to provide\ntheir own shared-libraries to support arbitrary hardware to work with\napplications based on OpenSSL 0.9.7 or later. If you're using an\napplication based on 0.9.7 (or later) and the support you desire is only\nannounced for versions later than the one you need, ask the vendor to\nbackport their ENGINE to the version you need.\n\nHow does \"dynamic\" work?\n------------------------\n\nThe dynamic ENGINE has a special flag in its implementation such that\nevery time application code asks for the 'dynamic' ENGINE, it in fact\ngets its own copy of it. As such, multi-threaded code (or code that\nmultiplexes multiple uses of 'dynamic' in a single application in any\nway at all) does not get confused by 'dynamic' being used to do many\nindependent things. Other ENGINEs typically don't do this so there is\nonly ever 1 ENGINE structure of its type (and reference counts are used\nto keep order). The dynamic ENGINE itself provides absolutely no\ncryptographic functionality, and any attempt to \"initialise\" the ENGINE\nautomatically fails. All it does provide are a few \"control commands\"\nthat can be used to control how it will load an external ENGINE\nimplementation from a shared-library. To see these control commands,\nuse the command-line;\n\n    openssl engine -vvvv dynamic\n\nThe \"SO_PATH\" control command should be used to identify the\nshared-library that contains the ENGINE implementation, and \"NO_VCHECK\"\nmight possibly be useful if there is a minor version conflict and you\n(or a vendor helpdesk) is convinced you can safely ignore it.\n\"ID\" is probably only needed if a shared-library implements\nmultiple ENGINEs, but if you know the engine id you expect to be using,\nit doesn't hurt to specify it (and this provides a sanity check if\nnothing else). \"LIST_ADD\" is only required if you actually wish the\nloaded ENGINE to be discoverable by application code later on using the\nENGINE's \"id\". For most applications, this isn't necessary - but some\napplication authors may have nifty reasons for using it. The \"LOAD\"\ncommand is the only one that takes no parameters and is the command\nthat uses the settings from any previous commands to actually *load*\nthe shared-library ENGINE implementation. If this command succeeds, the\n(copy of the) 'dynamic' ENGINE will magically morph into the ENGINE\nthat has been loaded from the shared-library. As such, any control\ncommands supported by the loaded ENGINE could then be executed as per\nnormal. For instance, if ENGINE \"foo\" is implemented in the shared-library\n\"libfoo.so\" and it supports some special control command \"CMD_FOO\", the\nfollowing code would load and use it (NB: obviously this code has no\nerror checking);\n\n    ENGINE *e = ENGINE_by_id(\"dynamic\");\n    ENGINE_ctrl_cmd_string(e, \"SO_PATH\", \"/lib/libfoo.so\", 0);\n    ENGINE_ctrl_cmd_string(e, \"ID\", \"foo\", 0);\n    ENGINE_ctrl_cmd_string(e, \"LOAD\", NULL, 0);\n    ENGINE_ctrl_cmd_string(e, \"CMD_FOO\", \"some input data\", 0);\n\nFor testing, the \"openssl engine\" utility can be useful for this sort\nof thing. For example the above code excerpt would achieve much the\nsame result as;\n\n    openssl engine dynamic \\\n              -pre SO_PATH:/lib/libfoo.so \\\n              -pre ID:foo \\\n              -pre LOAD \\\n              -pre \"CMD_FOO:some input data\"\n\nOr to simply see the list of commands supported by the \"foo\" ENGINE;\n\n    openssl engine -vvvv dynamic \\\n              -pre SO_PATH:/lib/libfoo.so \\\n              -pre ID:foo \\\n              -pre LOAD\n\nApplications that support the ENGINE API and more specifically, the\n\"control commands\" mechanism, will provide some way for you to pass\nsuch commands through to ENGINEs. As such, you would select \"dynamic\"\nas the ENGINE to use, and the parameters/commands you pass would\ncontrol the *actual* ENGINE used. Each command is actually a name-value\npair and the value can sometimes be omitted (eg. the \"LOAD\" command).\nWhilst the syntax demonstrated in \"openssl engine\" uses a colon to\nseparate the command name from the value, applications may provide\ntheir own syntax for making that separation (eg. a win32 registry\nkey-value pair may be used by some applications). The reason for the\n\"-pre\" syntax in the \"openssl engine\" utility is that some commands\nmight be issued to an ENGINE *after* it has been initialised for use.\nEg. if an ENGINE implementation requires a smart-card to be inserted\nduring initialisation (or a PIN to be typed, or whatever), there may be\na control command you can issue afterwards to \"forget\" the smart-card\nso that additional initialisation is no longer possible. In\napplications such as web-servers, where potentially volatile code may\nrun on the same host system, this may provide some arguable security\nvalue. In such a case, the command would be passed to the ENGINE after\nit has been initialised for use, and so the \"-post\" switch would be\nused instead. Applications may provide a different syntax for\nsupporting this distinction, and some may simply not provide it at all\n(\"-pre\" is almost always what you're after, in reality).\n\nHow do I build a \"dynamic\" ENGINE?\n----------------------------------\n\nThis question is trickier - currently OpenSSL bundles various ENGINE\nimplementations that are statically built in, and any application that\ncalls the \"ENGINE_load_builtin_engines()\" function will automatically\nhave all such ENGINEs available (and occupying memory). Applications\nthat don't call that function have no ENGINEs available like that and\nwould have to use \"dynamic\" to load any such ENGINE - but on the other\nhand such applications would only have the memory footprint of any\nENGINEs explicitly loaded using user/admin provided control commands.\nThe main advantage of not statically linking ENGINEs and only using\n\"dynamic\" for hardware support is that any installation using no\n\"external\" ENGINE suffers no unnecessary memory footprint from unused\nENGINEs. Likewise, installations that do require an ENGINE incur the\noverheads from only *that* ENGINE once it has been loaded.\n\nSounds good? Maybe, but currently building an ENGINE implementation as\na shared-library that can be loaded by \"dynamic\" isn't automated in\nOpenSSL's build process. It can be done manually quite easily however.\nSuch a shared-library can either be built with any OpenSSL code it\nneeds statically linked in, or it can link dynamically against OpenSSL\nif OpenSSL itself is built as a shared library. The instructions are\nthe same in each case, but in the former (statically linked any\ndependencies on OpenSSL) you must ensure OpenSSL is built with\nposition-independent code (\"PIC\"). The default OpenSSL compilation may\nalready specify the relevant flags to do this, but you should consult\nwith your compiler documentation if you are in any doubt.\n\nThis example will show building the \"atalla\" ENGINE in the\ncrypto/engine/ directory as a shared-library for use via the \"dynamic\"\nENGINE.\n\n1.  \"cd\" to the crypto/engine/ directory of a pre-compiled OpenSSL\n    source tree.\n\n2.  Recompile at least one source file so you can see all the compiler\n    flags (and syntax) being used to build normally. Eg;\n\n        touch hw_atalla.c ; make\n\n    will rebuild \"hw_atalla.o\" using all such flags.\n\n3.  Manually enter the same compilation line to compile the\n    \"hw_atalla.c\" file but with the following two changes;\n\n    - add \"-DENGINE_DYNAMIC_SUPPORT\" to the command line switches,\n    - change the output file from \"hw_atalla.o\" to something new,\n      eg. \"tmp_atalla.o\"\n\n4.  Link \"tmp_atalla.o\" into a shared-library using the top-level\n    OpenSSL libraries to resolve any dependencies. The syntax for doing\n    this depends heavily on your system/compiler and is a nightmare\n    known well to anyone who has worked with shared-library portability\n    before. 'gcc' on Linux, for example, would use the following syntax;\n\n        gcc -shared -o dyn_atalla.so tmp_atalla.o -L../.. -lcrypto\n\n5.  Test your shared library using \"openssl engine\" as explained in the\n    previous section. Eg. from the top-level directory, you might try\n\n        apps/openssl engine -vvvv dynamic \\\n              -pre SO_PATH:./crypto/engine/dyn_atalla.so -pre LOAD\n\nIf the shared-library loads successfully, you will see both \"-pre\"\ncommands marked as \"SUCCESS\" and the list of control commands\ndisplayed (because of \"-vvvv\") will be the control commands for the\n*atalla* ENGINE (ie. *not* the 'dynamic' ENGINE). You can also add\nthe \"-t\" switch to the utility if you want it to try and initialise\nthe atalla ENGINE for use to test any possible hardware/driver issues.\n\nPROBLEMS\n========\n\nIt seems like the ENGINE part doesn't work too well with CryptoSwift on Win32.\nA quick test done right before the release showed that trying \"openssl speed\n-engine cswift\" generated errors. If the DSO gets enabled, an attempt is made\nto write at memory address 0x00000002.\n","funding_links":["https://openssl-foundation.org/sponsorship/"],"categories":["C","Cryptography","Popular Open Source Implementations of SSL/TLS","Real-World Projects",":sun_with_face: Common Commands \u0026 CLI","加密、密码破解、字典","Frameworks and Libs","库和框架","Security"],"sub_categories":["Implementation Issues","Security","网络服务_其他","C"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenssl%2Fopenssl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenssl%2Fopenssl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenssl%2Fopenssl/lists"}