# multiotp/multiotp architecture

> Architecture diagram of the GitHub repository multiotp/multiotp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/multiotp/multiotp
- Repository: https://github.com/multiotp/multiotp

## Overview

multiOTP is a PHP two-factor authentication server and library. A typical request enters through the CLI or an integration, reaches the central authentication class, and is checked against user/token state to produce an authentication result. The README documents HOTP/TOTP, Yubikey, SMS and emergency TAN tokens, challenge-response protocols, LDAP/AD synchronization, QR provisioning and RADIUS/web-service use. The central class and several integrations are not excerpted, so links involving their internals are documented at a high level; library dependency edges are limited to references shown in the source index or excerpts.

Main entry points: [`contrib/SSH2.php`](https://github.com/multiotp/multiotp/blob/master/contrib/SSH2.php) (SSH transport), [`multiotp.class.php`](https://github.com/multiotp/multiotp/blob/master/multiotp.class.php) (Authentication engine), [`contrib/RSA.php`](https://github.com/multiotp/multiotp/blob/master/contrib/RSA.php) (RSA operations), [`contrib/Base.php`](https://github.com/multiotp/multiotp/blob/master/contrib/Base.php) (Cipher base)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Interfaces and integrations"]
  node_cli["Command-line interface"]
  node_server["Server interface"]
  node_radius["RADIUS service"]
  node_syslog["Syslog client<br/>[MultiotpSyslog.php]"]
end

subgraph group_auth["Authentication domain"]
  node_core["Authentication engine<br/>[multiotp.class.php]"]
  node_userstate[("User and token state<br/>[multiotp.class.php]")]
  node_otp["HOTP and TOTP<br/>[multiotp.class.php]"]
  node_challenge["CHAP protocols<br/>[multiotp.class.php]"]
  node_yubikey["Yubikey OTP"]
  node_sms["SMS tokens<br/>[MultiotpSms.php]"]
end

subgraph group_provision["Identity and provisioning"]
  node_ldap["AD and LDAP sync<br/>[MultiotpAdLdap.php]"]
  node_qrcode["QR provisioning<br/>[MultiotpQrcode.php]"]
  node_xml["XML parser"]
end

subgraph group_crypto["Cryptographic libraries"]
  node_asn1["ASN.1 encoding<br/>[ASN1.php]"]
  node_bigint["Big integers<br/>[BigInteger.php]"]
  node_base["Cipher base<br/>[Base.php]"]
  node_hash["Hash functions<br/>[Hash.php]"]
  node_rijndael["Rijndael cipher<br/>[Rijndael.php]"]
  node_des["DES cipher<br/>[DES.php]"]
  node_blowfish["Blowfish cipher<br/>[Blowfish.php]"]
  node_triple_des["Triple DES cipher<br/>[TripleDES.php]"]
  node_twofish["Twofish cipher<br/>[Twofish.php]"]
  node_random["Random source<br/>[Random.php]"]
  node_rsa["RSA operations<br/>[RSA.php]"]
  node_x509["X.509 certificates<br/>[X509.php]"]
  node_ssh["SSH transport<br/>[SSH2.php]"]
  node_sftp["SFTP client<br/>[SFTP.php]"]
end

node_operator(("Operator or client"))

node_operator -->|"runs command"| node_cli
node_cli -->|"constructs engine"| node_core
node_operator -.->|"sends request"| node_server
node_radius -.->|"requests authentication"| node_core
node_core -.->|"reads and writes"| node_userstate
node_core -->|"checks token"| node_otp
node_core -->|"checks challenge"| node_challenge
node_core -.->|"checks OTP"| node_yubikey
node_core -.->|"uses token provider"| node_sms
node_core -.->|"logs events"| node_syslog
node_operator -->|"requests sync"| node_ldap
node_core -.->|"provisions token"| node_qrcode
node_asn1 -->|"uses arithmetic"| node_bigint
node_base -->|"derives keys"| node_hash
node_rijndael -->|"extends cipher base"| node_base
node_des -->|"extends cipher base"| node_base
node_rsa -->|"uses arithmetic"| node_bigint
node_rsa -->|"uses hashes"| node_hash
node_rsa -->|"uses random source"| node_random
node_rsa -->|"uses cipher"| node_triple_des
node_x509 -->|"parses certificates"| node_asn1
node_x509 -->|"uses arithmetic"| node_bigint
node_x509 -->|"verifies signatures"| node_rsa
node_ssh -->|"uses arithmetic"| node_bigint
node_ssh -->|"uses random source"| node_random
node_ssh -->|"uses hashes"| node_hash
node_ssh -->|"uses cipher base"| node_base
node_ssh -->|"uses cipher"| node_rijndael
node_ssh -->|"uses cipher"| node_twofish
node_ssh -->|"uses cipher"| node_blowfish
node_ssh -->|"uses cipher"| node_triple_des
node_sftp -->|"uses transport"| node_ssh

click node_cli "https://github.com/multiotp/multiotp/blob/master/multiotp.cli.header.php"
click node_server "https://github.com/multiotp/multiotp/blob/master/multiotp.server.php"
click node_core "https://github.com/multiotp/multiotp/blob/master/multiotp.class.php"
click node_userstate "https://github.com/multiotp/multiotp/blob/master/multiotp.class.php"
click node_otp "https://github.com/multiotp/multiotp/blob/master/multiotp.class.php"
click node_challenge "https://github.com/multiotp/multiotp/blob/master/multiotp.class.php"
click node_yubikey "https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpYubikey.php"
click node_sms "https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpSms.php"
click node_syslog "https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpSyslog.php"
click node_ldap "https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpAdLdap.php"
click node_qrcode "https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpQrcode.php"
click node_xml "https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpXmlParser.php"
click node_asn1 "https://github.com/multiotp/multiotp/blob/master/contrib/ASN1.php"
click node_bigint "https://github.com/multiotp/multiotp/blob/master/contrib/BigInteger.php"
click node_base "https://github.com/multiotp/multiotp/blob/master/contrib/Base.php"
click node_hash "https://github.com/multiotp/multiotp/blob/master/contrib/Hash.php"
click node_rijndael "https://github.com/multiotp/multiotp/blob/master/contrib/Rijndael.php"
click node_des "https://github.com/multiotp/multiotp/blob/master/contrib/DES.php"
click node_blowfish "https://github.com/multiotp/multiotp/blob/master/contrib/Blowfish.php"
click node_triple_des "https://github.com/multiotp/multiotp/blob/master/contrib/TripleDES.php"
click node_twofish "https://github.com/multiotp/multiotp/blob/master/contrib/Twofish.php"
click node_random "https://github.com/multiotp/multiotp/blob/master/contrib/Random.php"
click node_rsa "https://github.com/multiotp/multiotp/blob/master/contrib/RSA.php"
click node_x509 "https://github.com/multiotp/multiotp/blob/master/contrib/X509.php"
click node_ssh "https://github.com/multiotp/multiotp/blob/master/contrib/SSH2.php"
click node_sftp "https://github.com/multiotp/multiotp/blob/master/contrib/SFTP.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_server,node_radius,node_syslog,node_operator toneBlue
class node_core,node_userstate,node_otp,node_challenge,node_yubikey,node_sms toneAmber
class node_ldap,node_qrcode,node_xml toneMint
class node_asn1,node_bigint,node_base,node_hash,node_rijndael,node_des,node_blowfish,node_triple_des,node_twofish,node_random,node_rsa,node_x509,node_ssh,node_sftp toneRose
```

## Components

### Interfaces and integrations

- [Command-line interface](https://github.com/multiotp/multiotp/blob/master/multiotp.cli.header.php): `multiotp.cli.header.php`
- [Server interface](https://github.com/multiotp/multiotp/blob/master/multiotp.server.php): `multiotp.server.php`
- **RADIUS service**
- [Syslog client](https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpSyslog.php): `contrib/MultiotpSyslog.php`

### Authentication domain

- [Authentication engine](https://github.com/multiotp/multiotp/blob/master/multiotp.class.php): `multiotp.class.php`
- [User and token state](https://github.com/multiotp/multiotp/blob/master/multiotp.class.php): `multiotp.class.php`
- [HOTP and TOTP](https://github.com/multiotp/multiotp/blob/master/multiotp.class.php): `multiotp.class.php`
- [CHAP protocols](https://github.com/multiotp/multiotp/blob/master/multiotp.class.php): `multiotp.class.php`
- [Yubikey OTP](https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpYubikey.php): `contrib/MultiotpYubikey.php`
- [SMS tokens](https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpSms.php): `contrib/MultiotpSms.php`

### Identity and provisioning

- [AD and LDAP sync](https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpAdLdap.php): `contrib/MultiotpAdLdap.php`
- [QR provisioning](https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpQrcode.php): `contrib/MultiotpQrcode.php`
- [XML parser](https://github.com/multiotp/multiotp/blob/master/contrib/MultiotpXmlParser.php): `contrib/MultiotpXmlParser.php`

### Cryptographic libraries

- [ASN.1 encoding](https://github.com/multiotp/multiotp/blob/master/contrib/ASN1.php): `contrib/ASN1.php`
- [Big integers](https://github.com/multiotp/multiotp/blob/master/contrib/BigInteger.php): `contrib/BigInteger.php`
- [Cipher base](https://github.com/multiotp/multiotp/blob/master/contrib/Base.php): `contrib/Base.php`
- [Hash functions](https://github.com/multiotp/multiotp/blob/master/contrib/Hash.php): `contrib/Hash.php`
- [Rijndael cipher](https://github.com/multiotp/multiotp/blob/master/contrib/Rijndael.php): `contrib/Rijndael.php`
- [DES cipher](https://github.com/multiotp/multiotp/blob/master/contrib/DES.php): `contrib/DES.php`
- [Blowfish cipher](https://github.com/multiotp/multiotp/blob/master/contrib/Blowfish.php): `contrib/Blowfish.php`
- [Triple DES cipher](https://github.com/multiotp/multiotp/blob/master/contrib/TripleDES.php): `contrib/TripleDES.php`
- [Twofish cipher](https://github.com/multiotp/multiotp/blob/master/contrib/Twofish.php): `contrib/Twofish.php`
- [Random source](https://github.com/multiotp/multiotp/blob/master/contrib/Random.php): `contrib/Random.php`
- [RSA operations](https://github.com/multiotp/multiotp/blob/master/contrib/RSA.php): `contrib/RSA.php`
- [X.509 certificates](https://github.com/multiotp/multiotp/blob/master/contrib/X509.php): `contrib/X509.php`
- [SSH transport](https://github.com/multiotp/multiotp/blob/master/contrib/SSH2.php): `contrib/SSH2.php`
- [SFTP client](https://github.com/multiotp/multiotp/blob/master/contrib/SFTP.php): `contrib/SFTP.php`

### Other components

- **Operator or client**

## Connections

- Operator or client → Command-line interface: runs command
- Command-line interface → Authentication engine: constructs engine (evidence: `multiotp.cli.header.php`)
- Operator or client → Server interface: sends request
- RADIUS service → Authentication engine: requests authentication
- Authentication engine → User and token state: reads and writes
- Authentication engine → HOTP and TOTP: checks token
- Authentication engine → CHAP protocols: checks challenge
- Authentication engine → Yubikey OTP: checks OTP
- Authentication engine → SMS tokens: uses token provider
- Authentication engine → Syslog client: logs events
- Operator or client → AD and LDAP sync: requests sync
- Authentication engine → QR provisioning: provisions token
- ASN.1 encoding → Big integers: uses arithmetic (evidence: `contrib/ASN1.php`)
- Cipher base → Hash functions: derives keys (evidence: `contrib/Base.php`)
- Rijndael cipher → Cipher base: extends cipher base (evidence: `contrib/Rijndael.php`)
- DES cipher → Cipher base: extends cipher base (evidence: `contrib/DES.php`)
- RSA operations → Big integers: uses arithmetic (evidence: `contrib/RSA.php`)
- RSA operations → Hash functions: uses hashes (evidence: `contrib/RSA.php`)
- RSA operations → Random source: uses random source (evidence: `contrib/RSA.php`)
- RSA operations → Triple DES cipher: uses cipher (evidence: `contrib/RSA.php`)
- X.509 certificates → ASN.1 encoding: parses certificates (evidence: `contrib/X509.php`)
- X.509 certificates → Big integers: uses arithmetic (evidence: `contrib/X509.php`)
- X.509 certificates → RSA operations: verifies signatures (evidence: `contrib/X509.php`)
- SSH transport → Big integers: uses arithmetic (evidence: `contrib/SSH2.php`)
- SSH transport → Random source: uses random source (evidence: `contrib/SSH2.php`)
- SSH transport → Hash functions: uses hashes (evidence: `contrib/SSH2.php`)
- SSH transport → Cipher base: uses cipher base (evidence: `contrib/SSH2.php`)
- SSH transport → Rijndael cipher: uses cipher (evidence: `contrib/SSH2.php`)
- SSH transport → Twofish cipher: uses cipher (evidence: `contrib/SSH2.php`)
- SSH transport → Blowfish cipher: uses cipher (evidence: `contrib/SSH2.php`)
- SSH transport → Triple DES cipher: uses cipher (evidence: `contrib/SSH2.php`)
- SFTP client → SSH transport: uses transport (evidence: `contrib/SFTP.php`)
