added device_supervisor app
This commit is contained in:
0
APPS/.gitkeep
Normal file
0
APPS/.gitkeep
Normal file
15
APPS/.vscode/sftp.json
vendored
Normal file
15
APPS/.vscode/sftp.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Debug Server",
|
||||
"host": "166.252.175.224",
|
||||
"protocol": "sftp",
|
||||
"port": 222,
|
||||
"username": "pyuser",
|
||||
"password":"Ste&(WdhXqH_",
|
||||
"remotePath": "/var/user/app/device_supervisor",
|
||||
"uploadOnSave": true,
|
||||
"ignore":[
|
||||
".vscode",
|
||||
".git",
|
||||
".DS_Store"
|
||||
]
|
||||
}
|
||||
BIN
APPS/BacnetbipDriver
Normal file
BIN
APPS/BacnetbipDriver
Normal file
Binary file not shown.
BIN
APPS/BacnetmstpDriver
Normal file
BIN
APPS/BacnetmstpDriver
Normal file
Binary file not shown.
BIN
APPS/DataHub
Normal file
BIN
APPS/DataHub
Normal file
Binary file not shown.
BIN
APPS/Dlt64507Driver
Normal file
BIN
APPS/Dlt64507Driver
Normal file
Binary file not shown.
BIN
APPS/Dlt64597Driver
Normal file
BIN
APPS/Dlt64597Driver
Normal file
Binary file not shown.
BIN
APPS/Dnp3Driver
Normal file
BIN
APPS/Dnp3Driver
Normal file
Binary file not shown.
BIN
APPS/Dnp3Server
Normal file
BIN
APPS/Dnp3Server
Normal file
Binary file not shown.
BIN
APPS/DriverAgent
Normal file
BIN
APPS/DriverAgent
Normal file
Binary file not shown.
BIN
APPS/EasyProtocolDriver
Normal file
BIN
APPS/EasyProtocolDriver
Normal file
Binary file not shown.
BIN
APPS/Euromap63Driver
Normal file
BIN
APPS/Euromap63Driver
Normal file
Binary file not shown.
BIN
APPS/HJ21205Driver
Normal file
BIN
APPS/HJ21205Driver
Normal file
Binary file not shown.
BIN
APPS/HJ212Driver
Normal file
BIN
APPS/HJ212Driver
Normal file
Binary file not shown.
BIN
APPS/ModbusDriver
Normal file
BIN
APPS/ModbusDriver
Normal file
Binary file not shown.
BIN
APPS/ModbusRtuSlaveDriver
Normal file
BIN
APPS/ModbusRtuSlaveDriver
Normal file
Binary file not shown.
BIN
APPS/ModbusSlave
Normal file
BIN
APPS/ModbusSlave
Normal file
Binary file not shown.
BIN
APPS/MqttAgent
Normal file
BIN
APPS/MqttAgent
Normal file
Binary file not shown.
BIN
APPS/OpcuaDriver
Normal file
BIN
APPS/OpcuaDriver
Normal file
Binary file not shown.
BIN
APPS/OpcuaPubSubDriver
Normal file
BIN
APPS/OpcuaPubSubDriver
Normal file
Binary file not shown.
BIN
APPS/OpcuaServer
Normal file
BIN
APPS/OpcuaServer
Normal file
Binary file not shown.
BIN
APPS/bacnetServer
Normal file
BIN
APPS/bacnetServer
Normal file
Binary file not shown.
0
APPS/build/.gitkeep
Normal file
0
APPS/build/.gitkeep
Normal file
BIN
APPS/cjt188Driver
Normal file
BIN
APPS/cjt188Driver
Normal file
Binary file not shown.
308
APPS/config.ini
Normal file
308
APPS/config.ini
Normal file
@@ -0,0 +1,308 @@
|
||||
{
|
||||
"controllers": [],
|
||||
"measures": [],
|
||||
"alarms": [],
|
||||
"alarmLables": ["default"],
|
||||
"groups": [
|
||||
{
|
||||
"_id":"group59b64649c93",
|
||||
"name": "default",
|
||||
"uploadInterval": 10,
|
||||
"LwTSDBSize": 1000,
|
||||
"strategy": 1,
|
||||
"enablePerOnchange": 0,
|
||||
"historyDataMode": "gateway",
|
||||
"historyDataPath": "/var/user/data/dbhome/device_supervisor/LwTSDB"
|
||||
}
|
||||
],
|
||||
"misc": {
|
||||
"maxAlarmRecordSz": 2000,
|
||||
"logLvl": "INFO",
|
||||
"coms": [
|
||||
{
|
||||
"name": "rs232",
|
||||
"baud": 9600,
|
||||
"bits": 8,
|
||||
"stopbits": 1,
|
||||
"parityChk": "n"
|
||||
},
|
||||
{
|
||||
"name": "rs485",
|
||||
"baud": 9600,
|
||||
"bits": 8,
|
||||
"stopbits": 1,
|
||||
"parityChk": "n"
|
||||
}
|
||||
],
|
||||
"cachePath": "/var/user/data/dbhome/device_supervisor/offlinedata",
|
||||
"cacheSize": 10000,
|
||||
"debugLogPath": "/var/user/data/dbhome/device_supervisor/debugLog",
|
||||
"debugLogSize": 2000,
|
||||
"cacheMode": "gateway",
|
||||
"cacheUploadPeriod": 200,
|
||||
"cacheStrategy": 0,
|
||||
"pubTimeout": 1000,
|
||||
"pubRepeatNum": 3,
|
||||
"debugLogMode": "gateway",
|
||||
"logNum": 2,
|
||||
"logSize": 1
|
||||
},
|
||||
"clouds": [
|
||||
{
|
||||
"_id": "cloud59b6464bd03",
|
||||
"cacheSize": 10000,
|
||||
"enable": 0,
|
||||
"name": "default",
|
||||
"type": "Standard MQTT",
|
||||
"args": {
|
||||
"host": "",
|
||||
"port": 1883,
|
||||
"clientId": "",
|
||||
"auth": 0,
|
||||
"tls": 0,
|
||||
"tlsAuth": "caSelfSigned",
|
||||
"groupId": "",
|
||||
"cleanSession": 0,
|
||||
"mqttVersion": "v3.1.1",
|
||||
"keepalive": 60,
|
||||
"key": "",
|
||||
"cert": "",
|
||||
"rootCA": "",
|
||||
"verifyServer": 0,
|
||||
"verifyClient": 0,
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"willQos": 0,
|
||||
"willRetain": 0,
|
||||
"willTopic": "",
|
||||
"willPayload": ""
|
||||
},
|
||||
"uploadRules": []
|
||||
}
|
||||
],
|
||||
"labels": [],
|
||||
"quickfaas": {
|
||||
"genericFuncs": [],
|
||||
"uploadFuncs": [],
|
||||
"downloadFuncs": []
|
||||
},
|
||||
"mindspheres": [
|
||||
{
|
||||
"name": "mindsphere",
|
||||
"enable": 0,
|
||||
"_id": "mindsphereeafcdf",
|
||||
"args": {
|
||||
"hostEnvironment": "eu1",
|
||||
"hostDomain": "mindsphere.io",
|
||||
"appName": "",
|
||||
"appVersion": "",
|
||||
"clientId": "",
|
||||
"clientSecret": "",
|
||||
"authType": "tenant",
|
||||
"hostTenant": "",
|
||||
"userTenant": "",
|
||||
"timeout": 10,
|
||||
"statusTimeout": 300,
|
||||
"enableOfflinePut": 0
|
||||
},
|
||||
"mindsphereputs": []
|
||||
}
|
||||
],
|
||||
"modbusSlave": {
|
||||
"enable": 0,
|
||||
"protocol": "Modbus-TCP",
|
||||
"port": 502,
|
||||
"slaveAddr": 1,
|
||||
"useRawvalue": 1,
|
||||
"int16Ord": "ab",
|
||||
"int32Ord": "abcd",
|
||||
"float32Ord": "abcd",
|
||||
"maxConnection": 5,
|
||||
"mapping_table":[],
|
||||
"mappingTable": [
|
||||
{
|
||||
"name": "1",
|
||||
"slaveAddr": 1,
|
||||
"_id": "modbusTCPSlave01",
|
||||
"measures": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"modbusRTUSlave": {
|
||||
"enable": 0,
|
||||
"protocol": "Modbus-RTU",
|
||||
"coms": "rs485",
|
||||
"useRawvalue": 1,
|
||||
"slaveAddr": 1,
|
||||
"int16Ord": "ab",
|
||||
"int32Ord": "abcd",
|
||||
"float32Ord": "abcd",
|
||||
"mapping_table":[],
|
||||
"mappingTable": [
|
||||
{
|
||||
"name": "1",
|
||||
"slaveAddr": 1,
|
||||
"_id": "modbusRTUSlave01",
|
||||
"measures": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"iec104Server": {
|
||||
"enable": 0,
|
||||
"cotSize": 2,
|
||||
"port": 2404,
|
||||
"asduLen": 2,
|
||||
"connectMode": "tcpServer",
|
||||
"enableSpontaneous": 1,
|
||||
"useRawvalue": 1,
|
||||
"serverList": [
|
||||
{
|
||||
"asduAddr": 1
|
||||
}
|
||||
],
|
||||
"kValue": 12,
|
||||
"wValue": 8,
|
||||
"t0": 30,
|
||||
"t1": 15,
|
||||
"t2": 10,
|
||||
"t3": 20,
|
||||
"maximumLink" : 5,
|
||||
"timeSet": 1,
|
||||
"byteOrder": "abcd",
|
||||
"mapping_table":[]
|
||||
},
|
||||
"iec101Server": {
|
||||
"enable": 0,
|
||||
"coms": "rs485",
|
||||
"mode": "UnBalance",
|
||||
"enableSpontaneous": 1,
|
||||
"protocolMode": 0,
|
||||
"useRawvalue": 1,
|
||||
"linkLen": 2,
|
||||
"linkAddr": 1,
|
||||
"asduLen": 2,
|
||||
"ioaLen": 3,
|
||||
"cotLen": 2,
|
||||
"serverList": [
|
||||
{
|
||||
"asduAddr": 1
|
||||
}
|
||||
],
|
||||
"linkTimeOut": 2000,
|
||||
"timeSet": 1,
|
||||
"idleTimeOut": 10000,
|
||||
"byteOrder": "abcd",
|
||||
"mappingTable": {
|
||||
"YX": [],
|
||||
"YC": [],
|
||||
"YK": []
|
||||
}
|
||||
},
|
||||
"iec104Client": {
|
||||
"enable": 0,
|
||||
"connectType": 2,
|
||||
"serverAddr": "ipower.inhandcloud.cn",
|
||||
"serverPort": 2406,
|
||||
"communicationCode": "",
|
||||
"protocol": 1,
|
||||
"asduAddr": 1,
|
||||
"tls": 1,
|
||||
"verification": 1,
|
||||
"mapping_table": {
|
||||
"YX": [],
|
||||
"YC": [],
|
||||
"YK": []
|
||||
}
|
||||
},
|
||||
"opcuaServer": {
|
||||
"enable": 0,
|
||||
"port": 4840,
|
||||
"maximumLink" : 5,
|
||||
"securityMode": 0,
|
||||
"certificate": "None",
|
||||
"privateKey": "None",
|
||||
"useRawvalue": 1,
|
||||
"identifierType": "String",
|
||||
"pubsub": 0,
|
||||
"mapping_table":[]
|
||||
},
|
||||
"iec61850Server": {
|
||||
"enable": 0,
|
||||
"protocol": "iec61850Server",
|
||||
"port": 102,
|
||||
"iedName": "INHAND",
|
||||
"LDName": "Gateway",
|
||||
"ctrlMode": 1,
|
||||
"authentication": 0,
|
||||
"password": "123456",
|
||||
"useRawvalue": 1,
|
||||
"dataSet": [],
|
||||
"mapping_table": []
|
||||
},
|
||||
"sl651Slave": {
|
||||
"enable": 0,
|
||||
"centerAaddr": 1,
|
||||
"remoteAddr": "",
|
||||
"addrCode": "",
|
||||
"password": "",
|
||||
"platform_list": [],
|
||||
"useRawvalue": 1,
|
||||
"mapping_table": []
|
||||
},
|
||||
"hj212Client": {
|
||||
"enable": 0,
|
||||
"useRawvalue": 1,
|
||||
"platform_list": [],
|
||||
"block_list": [],
|
||||
"mapping_table": []
|
||||
},
|
||||
"bacnetServer": {
|
||||
"enable": 0,
|
||||
"protocol": "BACnet/IP",
|
||||
"deviceId": 0,
|
||||
"port": 47808,
|
||||
"bbmdEnable": 0,
|
||||
"useRawvalue": 1,
|
||||
"mapping_table": []
|
||||
},
|
||||
"Dnp3Server": {
|
||||
"enable": 0,
|
||||
"protocol": "Dnp3-TCP",
|
||||
"slaveAddr": 1,
|
||||
"masterAddr": 2,
|
||||
"port": 20000,
|
||||
"useRawvalue": 1,
|
||||
"enableUnsol": 0,
|
||||
"maxFrasize": 4096,
|
||||
"layerTimeout": 1000,
|
||||
"linkRetry": 5,
|
||||
"enableLink": 0,
|
||||
"mapping_table": []
|
||||
},
|
||||
"snmpAgent": {
|
||||
"enable": 0,
|
||||
"port": 161,
|
||||
"useRawvalue": 1,
|
||||
"version": 3,
|
||||
"userName": "",
|
||||
"enableAuth": 0,
|
||||
"readWrite": "ro",
|
||||
"enable_trap": 0,
|
||||
"mapping_table": []
|
||||
},
|
||||
"templates": {},
|
||||
"bindConfig": {
|
||||
"enable": 0,
|
||||
"bind":{
|
||||
"modelId": "",
|
||||
"modelName": "",
|
||||
"srcId": "",
|
||||
"srcName": "",
|
||||
"devId": "",
|
||||
"devName": ""
|
||||
},
|
||||
"varGroups": [],
|
||||
"variables": [],
|
||||
"alerts":[]
|
||||
}
|
||||
}
|
||||
7
APPS/config.yaml
Normal file
7
APPS/config.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
config:
|
||||
description: "hello world!"
|
||||
others:
|
||||
LOG:
|
||||
#Enable debug feature to write all logs to the console
|
||||
#Default: debug=0
|
||||
debug: 1
|
||||
1
APPS/device_supervisor.info
Normal file
1
APPS/device_supervisor.info
Normal file
@@ -0,0 +1 @@
|
||||
{"name": "device_supervisor", "version": "3.1.5", "sdk_version": "1.4.5", "author": ""}
|
||||
BIN
APPS/exportHistoryData
Normal file
BIN
APPS/exportHistoryData
Normal file
Binary file not shown.
BIN
APPS/hj212Client
Normal file
BIN
APPS/hj212Client
Normal file
Binary file not shown.
BIN
APPS/iec104Client
Normal file
BIN
APPS/iec104Client
Normal file
Binary file not shown.
BIN
APPS/iec61850Driver
Normal file
BIN
APPS/iec61850Driver
Normal file
Binary file not shown.
BIN
APPS/iec61850FileTool
Normal file
BIN
APPS/iec61850FileTool
Normal file
Binary file not shown.
BIN
APPS/iec61850Server
Normal file
BIN
APPS/iec61850Server
Normal file
Binary file not shown.
BIN
APPS/iecMaster
Normal file
BIN
APPS/iecMaster
Normal file
Binary file not shown.
BIN
APPS/iecSlave
Normal file
BIN
APPS/iecSlave
Normal file
Binary file not shown.
BIN
APPS/kebaSocketDriver
Normal file
BIN
APPS/kebaSocketDriver
Normal file
Binary file not shown.
0
APPS/lib/.gitkeep
Normal file
0
APPS/lib/.gitkeep
Normal file
1
APPS/lib/APScheduler-3.6.3.dist-info/INSTALLER
Normal file
1
APPS/lib/APScheduler-3.6.3.dist-info/INSTALLER
Normal file
@@ -0,0 +1 @@
|
||||
pip
|
||||
19
APPS/lib/APScheduler-3.6.3.dist-info/LICENSE.txt
Normal file
19
APPS/lib/APScheduler-3.6.3.dist-info/LICENSE.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
Copyright (c) Alex Grönholm
|
||||
|
||||
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.
|
||||
133
APPS/lib/APScheduler-3.6.3.dist-info/METADATA
Normal file
133
APPS/lib/APScheduler-3.6.3.dist-info/METADATA
Normal file
@@ -0,0 +1,133 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: APScheduler
|
||||
Version: 3.6.3
|
||||
Summary: In-process task scheduler with Cron-like capabilities
|
||||
Home-page: https://github.com/agronholm/apscheduler
|
||||
Author: Alex Grönholm
|
||||
Author-email: apscheduler@nextday.fi
|
||||
License: MIT
|
||||
Keywords: scheduling cron
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Requires-Dist: setuptools (>=0.7)
|
||||
Requires-Dist: six (>=1.4.0)
|
||||
Requires-Dist: pytz
|
||||
Requires-Dist: tzlocal (>=1.2)
|
||||
Requires-Dist: futures ; python_version == "2.7"
|
||||
Requires-Dist: funcsigs ; python_version == "2.7"
|
||||
Provides-Extra: asyncio
|
||||
Requires-Dist: trollius ; (python_version == "2.7") and extra == 'asyncio'
|
||||
Provides-Extra: doc
|
||||
Requires-Dist: sphinx ; extra == 'doc'
|
||||
Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
|
||||
Provides-Extra: gevent
|
||||
Requires-Dist: gevent ; extra == 'gevent'
|
||||
Provides-Extra: mongodb
|
||||
Requires-Dist: pymongo (>=2.8) ; extra == 'mongodb'
|
||||
Provides-Extra: redis
|
||||
Requires-Dist: redis (>=3.0) ; extra == 'redis'
|
||||
Provides-Extra: rethinkdb
|
||||
Requires-Dist: rethinkdb (>=2.4.0) ; extra == 'rethinkdb'
|
||||
Provides-Extra: sqlalchemy
|
||||
Requires-Dist: sqlalchemy (>=0.8) ; extra == 'sqlalchemy'
|
||||
Provides-Extra: testing
|
||||
Requires-Dist: pytest ; extra == 'testing'
|
||||
Requires-Dist: pytest-cov ; extra == 'testing'
|
||||
Requires-Dist: pytest-tornado5 ; extra == 'testing'
|
||||
Requires-Dist: mock ; (python_version == "2.7") and extra == 'testing'
|
||||
Requires-Dist: pytest-asyncio (<0.6) ; (python_version == "3.4") and extra == 'testing'
|
||||
Requires-Dist: pytest-asyncio ; (python_version >= "3.5") and extra == 'testing'
|
||||
Provides-Extra: tornado
|
||||
Requires-Dist: tornado (>=4.3) ; extra == 'tornado'
|
||||
Provides-Extra: twisted
|
||||
Requires-Dist: twisted ; extra == 'twisted'
|
||||
Provides-Extra: zookeeper
|
||||
Requires-Dist: kazoo ; extra == 'zookeeper'
|
||||
|
||||
.. image:: https://travis-ci.com/agronholm/apscheduler.svg?branch=master
|
||||
:target: https://travis-ci.com/agronholm/apscheduler
|
||||
:alt: Build Status
|
||||
.. image:: https://coveralls.io/repos/github/agronholm/apscheduler/badge.svg?branch=master
|
||||
:target: https://coveralls.io/github/agronholm/apscheduler?branch=master
|
||||
:alt: Code Coverage
|
||||
|
||||
Advanced Python Scheduler (APScheduler) is a Python library that lets you schedule your Python code
|
||||
to be executed later, either just once or periodically. You can add new jobs or remove old ones on
|
||||
the fly as you please. If you store your jobs in a database, they will also survive scheduler
|
||||
restarts and maintain their state. When the scheduler is restarted, it will then run all the jobs
|
||||
it should have run while it was offline [#f1]_.
|
||||
|
||||
Among other things, APScheduler can be used as a cross-platform, application specific replacement
|
||||
to platform specific schedulers, such as the cron daemon or the Windows task scheduler. Please
|
||||
note, however, that APScheduler is **not** a daemon or service itself, nor does it come with any
|
||||
command line tools. It is primarily meant to be run inside existing applications. That said,
|
||||
APScheduler does provide some building blocks for you to build a scheduler service or to run a
|
||||
dedicated scheduler process.
|
||||
|
||||
APScheduler has three built-in scheduling systems you can use:
|
||||
|
||||
* Cron-style scheduling (with optional start/end times)
|
||||
* Interval-based execution (runs jobs on even intervals, with optional start/end times)
|
||||
* One-off delayed execution (runs jobs once, on a set date/time)
|
||||
|
||||
You can mix and match scheduling systems and the backends where the jobs are stored any way you
|
||||
like. Supported backends for storing jobs include:
|
||||
|
||||
* Memory
|
||||
* `SQLAlchemy <http://www.sqlalchemy.org/>`_ (any RDBMS supported by SQLAlchemy works)
|
||||
* `MongoDB <http://www.mongodb.org/>`_
|
||||
* `Redis <http://redis.io/>`_
|
||||
* `RethinkDB <https://www.rethinkdb.com/>`_
|
||||
* `ZooKeeper <https://zookeeper.apache.org/>`_
|
||||
|
||||
APScheduler also integrates with several common Python frameworks, like:
|
||||
|
||||
* `asyncio <http://docs.python.org/3.4/library/asyncio.html>`_ (:pep:`3156`)
|
||||
* `gevent <http://www.gevent.org/>`_
|
||||
* `Tornado <http://www.tornadoweb.org/>`_
|
||||
* `Twisted <http://twistedmatrix.com/>`_
|
||||
* `Qt <http://qt-project.org/>`_ (using either
|
||||
`PyQt <http://www.riverbankcomputing.com/software/pyqt/intro>`_ or
|
||||
`PySide <http://qt-project.org/wiki/PySide>`_)
|
||||
|
||||
.. [#f1] The cutoff period for this is also configurable.
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Documentation can be found `here <http://readthedocs.org/docs/apscheduler/en/latest/>`_.
|
||||
|
||||
|
||||
Source
|
||||
------
|
||||
|
||||
The source can be browsed at `Github <https://github.com/agronholm/apscheduler>`_.
|
||||
|
||||
|
||||
Reporting bugs
|
||||
--------------
|
||||
|
||||
A `bug tracker <https://github.com/agronholm/apscheduler/issues>`_ is provided by Github.
|
||||
|
||||
|
||||
Getting help
|
||||
------------
|
||||
|
||||
If you have problems or other questions, you can either:
|
||||
|
||||
* Ask in the `apscheduler <https://gitter.im/apscheduler/Lobby>`_ room on Gitter
|
||||
* Ask on the `APScheduler Google group <http://groups.google.com/group/apscheduler>`_, or
|
||||
* Ask on `StackOverflow <http://stackoverflow.com/questions/tagged/apscheduler>`_ and tag your
|
||||
question with the ``apscheduler`` tag
|
||||
|
||||
|
||||
83
APPS/lib/APScheduler-3.6.3.dist-info/RECORD
Normal file
83
APPS/lib/APScheduler-3.6.3.dist-info/RECORD
Normal file
@@ -0,0 +1,83 @@
|
||||
APScheduler-3.6.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
APScheduler-3.6.3.dist-info/LICENSE.txt,sha256=YWP3mH37ONa8MgzitwsvArhivEESZRbVUu8c1DJH51g,1130
|
||||
APScheduler-3.6.3.dist-info/METADATA,sha256=VHah1X4AqMCGgcvEm06M-pAqmNC9q4tOQRbUv3b0Jh0,5398
|
||||
APScheduler-3.6.3.dist-info/RECORD,,
|
||||
APScheduler-3.6.3.dist-info/WHEEL,sha256=8zNYZbwQSXoB9IfXOjPfeNwvAsALAjffgk27FqvCWbo,110
|
||||
APScheduler-3.6.3.dist-info/entry_points.txt,sha256=7RgkYN_OYyCUQtIGhj-UNcelnIjsNm7nC9rogdMQh3U,1148
|
||||
APScheduler-3.6.3.dist-info/top_level.txt,sha256=O3oMCWxG-AHkecUoO6Ze7-yYjWrttL95uHO8-RFdYvE,12
|
||||
apscheduler/__init__.py,sha256=qFEK2ysRBcLiYmm3deyJJ1avUOugaM_nCGHMD42WMBw,380
|
||||
apscheduler/__pycache__/__init__.cpython-37.pyc,,
|
||||
apscheduler/__pycache__/events.cpython-37.pyc,,
|
||||
apscheduler/__pycache__/job.cpython-37.pyc,,
|
||||
apscheduler/__pycache__/util.cpython-37.pyc,,
|
||||
apscheduler/events.py,sha256=KRMTDQUS6d2uVnrQvPoz3ZPV5V9XKsCAZLsgx913FFo,3593
|
||||
apscheduler/executors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
apscheduler/executors/__pycache__/__init__.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/asyncio.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/base.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/base_py3.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/debug.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/gevent.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/pool.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/tornado.cpython-37.pyc,,
|
||||
apscheduler/executors/__pycache__/twisted.cpython-37.pyc,,
|
||||
apscheduler/executors/asyncio.py,sha256=ji5f6Qm2uGhov-3w52CXHZi8jc5U_gS56lisQylKTBQ,2087
|
||||
apscheduler/executors/base.py,sha256=hogiMc_t-huw6BMod0HEeY2FhRNmAAUyNNuBHvIX31M,5336
|
||||
apscheduler/executors/base_py3.py,sha256=s_4siAjBHrr7JZnm64VVow9zyvs2JBc-VRPkPuDeBTI,1775
|
||||
apscheduler/executors/debug.py,sha256=15_ogSBzl8RRCfBYDnkIV2uMH8cLk1KImYmBa_NVGpc,573
|
||||
apscheduler/executors/gevent.py,sha256=aulrNmoefyBgrOkH9awRhFiXIDnSCnZ4U0o0_JXIXgc,777
|
||||
apscheduler/executors/pool.py,sha256=q9TC6KzwWI9tpLNxQhdrKRWFtsN5dmx_Vegu23BV-Sk,1672
|
||||
apscheduler/executors/tornado.py,sha256=DU75VaQ9R6nBuy8lbPUvDKUgsuJcZqwAvURC5vg3r6w,1780
|
||||
apscheduler/executors/twisted.py,sha256=bRoU0C4BoVcS6_BjKD5wfUs0IJpGkmLsRAcMH2rJJss,778
|
||||
apscheduler/job.py,sha256=zT9_GuOpxuxEPVZU38tantw9383tAPRBPoH6dd4uHGA,11088
|
||||
apscheduler/jobstores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
apscheduler/jobstores/__pycache__/__init__.cpython-37.pyc,,
|
||||
apscheduler/jobstores/__pycache__/base.cpython-37.pyc,,
|
||||
apscheduler/jobstores/__pycache__/memory.cpython-37.pyc,,
|
||||
apscheduler/jobstores/__pycache__/mongodb.cpython-37.pyc,,
|
||||
apscheduler/jobstores/__pycache__/redis.cpython-37.pyc,,
|
||||
apscheduler/jobstores/__pycache__/rethinkdb.cpython-37.pyc,,
|
||||
apscheduler/jobstores/__pycache__/sqlalchemy.cpython-37.pyc,,
|
||||
apscheduler/jobstores/__pycache__/zookeeper.cpython-37.pyc,,
|
||||
apscheduler/jobstores/base.py,sha256=DXzSW9XscueHZHMvy1qFiG-vYqUl_MMv0n0uBSZWXGo,4523
|
||||
apscheduler/jobstores/memory.py,sha256=ZxWiKsqfsCHFvac-6X9BztuhnuSxlOYi1dhT6g-pjQo,3655
|
||||
apscheduler/jobstores/mongodb.py,sha256=e9KNzPFrjiVpiM3iPT_c0ONxZQT70VCF2rDXW0-22zk,5296
|
||||
apscheduler/jobstores/redis.py,sha256=kjQDIzPXz-Yq976U9HK3aMkcCI_QRLKgTADQWKewtik,5483
|
||||
apscheduler/jobstores/rethinkdb.py,sha256=k1rSLYJqejuhQxJY3pXwHAQYcpZ1QFJsoQ8n0oEu5MM,5863
|
||||
apscheduler/jobstores/sqlalchemy.py,sha256=5H5T05cQ2ZtkRuRb8hKkcLzZSQneAT13NMKXby3nzWE,6122
|
||||
apscheduler/jobstores/zookeeper.py,sha256=BzyqZ08XIDcbu5frQWGmDVEHAEScNxjt8oML6Tty8j8,6406
|
||||
apscheduler/schedulers/__init__.py,sha256=jM63xA_K7GSToBenhsz-SCcqfhk1pdEVb6ajwoO5Kqg,406
|
||||
apscheduler/schedulers/__pycache__/__init__.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/asyncio.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/background.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/base.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/blocking.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/gevent.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/qt.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/tornado.cpython-37.pyc,,
|
||||
apscheduler/schedulers/__pycache__/twisted.cpython-37.pyc,,
|
||||
apscheduler/schedulers/asyncio.py,sha256=0j0mcDpf-zI_vQHcUCZZtBfEEZEiocEOZ767efIZ5YM,2082
|
||||
apscheduler/schedulers/background.py,sha256=dGX0T0z6T6HzZHG7njWgp90SFHpetZ4ZBUV2gGOSqoc,1505
|
||||
apscheduler/schedulers/base.py,sha256=EUGbQ5R2jGA4PEEehU2ASuKVe0SsLqtWESAtTqAJW50,42863
|
||||
apscheduler/schedulers/blocking.py,sha256=c-5YR-dKn3D82tPt38t50KGPJrAiC852v8ai2Vwanmg,924
|
||||
apscheduler/schedulers/gevent.py,sha256=csPBvV75FGcboXXsdex6fCD7J54QgBddYNdWj62ZO9g,1031
|
||||
apscheduler/schedulers/qt.py,sha256=AhHU62ybOOVSD4OhMwoPRRUCoM5cf5q26uD3hPglfnc,1297
|
||||
apscheduler/schedulers/tornado.py,sha256=D9Vaq3Ee9EFiXa1jDy9tedI048gR_YT_LAFUWqO_uEw,1926
|
||||
apscheduler/schedulers/twisted.py,sha256=D5EBjjMRtMBxy0_aAURcULAI8Ky2IvCTr9tK9sO1rYk,1844
|
||||
apscheduler/triggers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
apscheduler/triggers/__pycache__/__init__.cpython-37.pyc,,
|
||||
apscheduler/triggers/__pycache__/base.cpython-37.pyc,,
|
||||
apscheduler/triggers/__pycache__/combining.cpython-37.pyc,,
|
||||
apscheduler/triggers/__pycache__/date.cpython-37.pyc,,
|
||||
apscheduler/triggers/__pycache__/interval.cpython-37.pyc,,
|
||||
apscheduler/triggers/base.py,sha256=WMo5f2g14fjO5VzpIxFQtk47Z9VEUDDPSxjoPL9FGSQ,1837
|
||||
apscheduler/triggers/combining.py,sha256=WTEnaEkBHysF1009sCvBaQa99hiy9l5Oz-hHyjy3jv8,3473
|
||||
apscheduler/triggers/cron/__init__.py,sha256=a8ASzvM7ci-djOI2jIL2XErL6zEx4Wr1012aD1XJw_w,9246
|
||||
apscheduler/triggers/cron/__pycache__/__init__.cpython-37.pyc,,
|
||||
apscheduler/triggers/cron/__pycache__/expressions.cpython-37.pyc,,
|
||||
apscheduler/triggers/cron/__pycache__/fields.cpython-37.pyc,,
|
||||
apscheduler/triggers/cron/expressions.py,sha256=hu1kq0mKvivIw7U0D0Nnrbuk3q01dCuhZ7SHRPw6qhI,9184
|
||||
apscheduler/triggers/cron/fields.py,sha256=NWPClh1NgSOpTlJ3sm1TXM_ViC2qJGKWkd_vg0xsw7o,3510
|
||||
apscheduler/triggers/date.py,sha256=RrfB1PNO9G9e91p1BOf-y_TseVHQQR-KJPhNdPpAHcU,1705
|
||||
apscheduler/triggers/interval.py,sha256=LiIunGOd96yaiAceG1XGP8eY3JxSyHDWCipVhQWMzDU,4381
|
||||
apscheduler/util.py,sha256=bQLVYP-RHtjypxol40a_JPT1Ta9BYSlTNdsDTc7dNMU,13963
|
||||
6
APPS/lib/APScheduler-3.6.3.dist-info/WHEEL
Normal file
6
APPS/lib/APScheduler-3.6.3.dist-info/WHEEL
Normal file
@@ -0,0 +1,6 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.33.6)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
24
APPS/lib/APScheduler-3.6.3.dist-info/entry_points.txt
Normal file
24
APPS/lib/APScheduler-3.6.3.dist-info/entry_points.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
[apscheduler.executors]
|
||||
asyncio = apscheduler.executors.asyncio:AsyncIOExecutor [asyncio]
|
||||
debug = apscheduler.executors.debug:DebugExecutor
|
||||
gevent = apscheduler.executors.gevent:GeventExecutor [gevent]
|
||||
processpool = apscheduler.executors.pool:ProcessPoolExecutor
|
||||
threadpool = apscheduler.executors.pool:ThreadPoolExecutor
|
||||
tornado = apscheduler.executors.tornado:TornadoExecutor [tornado]
|
||||
twisted = apscheduler.executors.twisted:TwistedExecutor [twisted]
|
||||
|
||||
[apscheduler.jobstores]
|
||||
memory = apscheduler.jobstores.memory:MemoryJobStore
|
||||
mongodb = apscheduler.jobstores.mongodb:MongoDBJobStore [mongodb]
|
||||
redis = apscheduler.jobstores.redis:RedisJobStore [redis]
|
||||
rethinkdb = apscheduler.jobstores.rethinkdb:RethinkDBJobStore [rethinkdb]
|
||||
sqlalchemy = apscheduler.jobstores.sqlalchemy:SQLAlchemyJobStore [sqlalchemy]
|
||||
zookeeper = apscheduler.jobstores.zookeeper:ZooKeeperJobStore [zookeeper]
|
||||
|
||||
[apscheduler.triggers]
|
||||
and = apscheduler.triggers.combining:AndTrigger
|
||||
cron = apscheduler.triggers.cron:CronTrigger
|
||||
date = apscheduler.triggers.date:DateTrigger
|
||||
interval = apscheduler.triggers.interval:IntervalTrigger
|
||||
or = apscheduler.triggers.combining:OrTrigger
|
||||
|
||||
1
APPS/lib/APScheduler-3.6.3.dist-info/top_level.txt
Normal file
1
APPS/lib/APScheduler-3.6.3.dist-info/top_level.txt
Normal file
@@ -0,0 +1 @@
|
||||
apscheduler
|
||||
22
APPS/lib/AWSIoTPythonSDK-1.4.9-py3.7.egg-info/PKG-INFO
Normal file
22
APPS/lib/AWSIoTPythonSDK-1.4.9-py3.7.egg-info/PKG-INFO
Normal file
@@ -0,0 +1,22 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: AWSIoTPythonSDK
|
||||
Version: 1.4.9
|
||||
Summary: SDK for connecting to AWS IoT using Python.
|
||||
Home-page: https://github.com/aws/aws-iot-device-sdk-python.git
|
||||
Author: Amazon Web Service
|
||||
Author-email: UNKNOWN
|
||||
License: UNKNOWN
|
||||
Download-URL: https://s3.amazonaws.com/aws-iot-device-sdk-python/aws-iot-device-sdk-python-latest.zip
|
||||
Description: UNKNOWN
|
||||
Keywords: aws,iot,mqtt
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: Natural Language :: English
|
||||
Classifier: License :: OSI Approved :: Apache Software License
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
40
APPS/lib/AWSIoTPythonSDK-1.4.9-py3.7.egg-info/SOURCES.txt
Normal file
40
APPS/lib/AWSIoTPythonSDK-1.4.9-py3.7.egg-info/SOURCES.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
README.rst
|
||||
setup.cfg
|
||||
setup.py
|
||||
AWSIoTPythonSDK/MQTTLib.py
|
||||
AWSIoTPythonSDK/__init__.py
|
||||
AWSIoTPythonSDK.egg-info/PKG-INFO
|
||||
AWSIoTPythonSDK.egg-info/SOURCES.txt
|
||||
AWSIoTPythonSDK.egg-info/dependency_links.txt
|
||||
AWSIoTPythonSDK.egg-info/top_level.txt
|
||||
AWSIoTPythonSDK/core/__init__.py
|
||||
AWSIoTPythonSDK/core/greengrass/__init__.py
|
||||
AWSIoTPythonSDK/core/greengrass/discovery/__init__.py
|
||||
AWSIoTPythonSDK/core/greengrass/discovery/models.py
|
||||
AWSIoTPythonSDK/core/greengrass/discovery/providers.py
|
||||
AWSIoTPythonSDK/core/jobs/__init__.py
|
||||
AWSIoTPythonSDK/core/jobs/thingJobManager.py
|
||||
AWSIoTPythonSDK/core/protocol/__init__.py
|
||||
AWSIoTPythonSDK/core/protocol/mqtt_core.py
|
||||
AWSIoTPythonSDK/core/protocol/connection/__init__.py
|
||||
AWSIoTPythonSDK/core/protocol/connection/alpn.py
|
||||
AWSIoTPythonSDK/core/protocol/connection/cores.py
|
||||
AWSIoTPythonSDK/core/protocol/internal/__init__.py
|
||||
AWSIoTPythonSDK/core/protocol/internal/clients.py
|
||||
AWSIoTPythonSDK/core/protocol/internal/defaults.py
|
||||
AWSIoTPythonSDK/core/protocol/internal/events.py
|
||||
AWSIoTPythonSDK/core/protocol/internal/queues.py
|
||||
AWSIoTPythonSDK/core/protocol/internal/requests.py
|
||||
AWSIoTPythonSDK/core/protocol/internal/workers.py
|
||||
AWSIoTPythonSDK/core/protocol/paho/__init__.py
|
||||
AWSIoTPythonSDK/core/protocol/paho/client.py
|
||||
AWSIoTPythonSDK/core/shadow/__init__.py
|
||||
AWSIoTPythonSDK/core/shadow/deviceShadow.py
|
||||
AWSIoTPythonSDK/core/shadow/shadowManager.py
|
||||
AWSIoTPythonSDK/core/util/__init__.py
|
||||
AWSIoTPythonSDK/core/util/enums.py
|
||||
AWSIoTPythonSDK/core/util/providers.py
|
||||
AWSIoTPythonSDK/exception/AWSIoTExceptions.py
|
||||
AWSIoTPythonSDK/exception/__init__.py
|
||||
AWSIoTPythonSDK/exception/operationError.py
|
||||
AWSIoTPythonSDK/exception/operationTimeoutException.py
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
../AWSIoTPythonSDK/MQTTLib.py
|
||||
../AWSIoTPythonSDK/__init__.py
|
||||
../AWSIoTPythonSDK/__pycache__/MQTTLib.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/__init__.py
|
||||
../AWSIoTPythonSDK/core/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/greengrass/__init__.py
|
||||
../AWSIoTPythonSDK/core/greengrass/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/greengrass/discovery/__init__.py
|
||||
../AWSIoTPythonSDK/core/greengrass/discovery/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/greengrass/discovery/__pycache__/models.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/greengrass/discovery/__pycache__/providers.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/greengrass/discovery/models.py
|
||||
../AWSIoTPythonSDK/core/greengrass/discovery/providers.py
|
||||
../AWSIoTPythonSDK/core/jobs/__init__.py
|
||||
../AWSIoTPythonSDK/core/jobs/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/jobs/__pycache__/thingJobManager.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/jobs/thingJobManager.py
|
||||
../AWSIoTPythonSDK/core/protocol/__init__.py
|
||||
../AWSIoTPythonSDK/core/protocol/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/__pycache__/mqtt_core.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/connection/__init__.py
|
||||
../AWSIoTPythonSDK/core/protocol/connection/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/connection/__pycache__/alpn.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/connection/__pycache__/cores.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/connection/alpn.py
|
||||
../AWSIoTPythonSDK/core/protocol/connection/cores.py
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__init__.py
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__pycache__/clients.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__pycache__/defaults.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__pycache__/events.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__pycache__/queues.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__pycache__/requests.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/internal/__pycache__/workers.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/internal/clients.py
|
||||
../AWSIoTPythonSDK/core/protocol/internal/defaults.py
|
||||
../AWSIoTPythonSDK/core/protocol/internal/events.py
|
||||
../AWSIoTPythonSDK/core/protocol/internal/queues.py
|
||||
../AWSIoTPythonSDK/core/protocol/internal/requests.py
|
||||
../AWSIoTPythonSDK/core/protocol/internal/workers.py
|
||||
../AWSIoTPythonSDK/core/protocol/mqtt_core.py
|
||||
../AWSIoTPythonSDK/core/protocol/paho/__init__.py
|
||||
../AWSIoTPythonSDK/core/protocol/paho/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/paho/__pycache__/client.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/protocol/paho/client.py
|
||||
../AWSIoTPythonSDK/core/shadow/__init__.py
|
||||
../AWSIoTPythonSDK/core/shadow/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/shadow/__pycache__/deviceShadow.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/shadow/__pycache__/shadowManager.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/shadow/deviceShadow.py
|
||||
../AWSIoTPythonSDK/core/shadow/shadowManager.py
|
||||
../AWSIoTPythonSDK/core/util/__init__.py
|
||||
../AWSIoTPythonSDK/core/util/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/util/__pycache__/enums.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/util/__pycache__/providers.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/core/util/enums.py
|
||||
../AWSIoTPythonSDK/core/util/providers.py
|
||||
../AWSIoTPythonSDK/exception/AWSIoTExceptions.py
|
||||
../AWSIoTPythonSDK/exception/__init__.py
|
||||
../AWSIoTPythonSDK/exception/__pycache__/AWSIoTExceptions.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/exception/__pycache__/__init__.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/exception/__pycache__/operationError.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/exception/__pycache__/operationTimeoutException.cpython-37.pyc
|
||||
../AWSIoTPythonSDK/exception/operationError.py
|
||||
../AWSIoTPythonSDK/exception/operationTimeoutException.py
|
||||
PKG-INFO
|
||||
SOURCES.txt
|
||||
dependency_links.txt
|
||||
top_level.txt
|
||||
@@ -0,0 +1 @@
|
||||
AWSIoTPythonSDK
|
||||
BIN
APPS/lib/AWSIoTPythonSDK/MQTTLib.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/MQTTLib.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/discovery/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/discovery/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/discovery/models.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/discovery/models.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/discovery/providers.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/greengrass/discovery/providers.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/jobs/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/jobs/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/jobs/thingJobManager.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/jobs/thingJobManager.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/connection/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/connection/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/connection/alpn.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/connection/alpn.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/connection/cores.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/connection/cores.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/clients.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/clients.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/defaults.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/defaults.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/events.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/events.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/queues.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/queues.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/requests.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/requests.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/workers.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/internal/workers.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/mqtt_core.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/mqtt_core.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/paho/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/paho/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/paho/client.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/protocol/paho/client.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/shadow/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/shadow/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/shadow/deviceShadow.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/shadow/deviceShadow.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/shadow/shadowManager.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/shadow/shadowManager.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/util/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/util/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/util/enums.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/util/enums.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/core/util/providers.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/core/util/providers.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/exception/AWSIoTExceptions.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/exception/AWSIoTExceptions.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/exception/__init__.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/exception/__init__.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/exception/operationError.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/exception/operationError.pyc
Normal file
Binary file not shown.
BIN
APPS/lib/AWSIoTPythonSDK/exception/operationTimeoutException.pyc
Normal file
BIN
APPS/lib/AWSIoTPythonSDK/exception/operationTimeoutException.pyc
Normal file
Binary file not shown.
1
APPS/lib/Autologging-1.3.2.dist-info/INSTALLER
Normal file
1
APPS/lib/Autologging-1.3.2.dist-info/INSTALLER
Normal file
@@ -0,0 +1 @@
|
||||
pip
|
||||
187
APPS/lib/Autologging-1.3.2.dist-info/METADATA
Normal file
187
APPS/lib/Autologging-1.3.2.dist-info/METADATA
Normal file
@@ -0,0 +1,187 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: Autologging
|
||||
Version: 1.3.2
|
||||
Summary: Autologging makes logging and tracing Python classes easy.
|
||||
Home-page: http://ninthtest.info/python-autologging/
|
||||
Author: Matthew Zipay
|
||||
Author-email: mattz@ninthtest.info
|
||||
License: MIT License
|
||||
Download-URL: https://sourceforge.net/projects/autologging/files/
|
||||
Keywords: logging,tracing
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Classifier: Programming Language :: Python :: Implementation :: CPython
|
||||
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
||||
Classifier: Programming Language :: Python :: Implementation :: Stackless
|
||||
Classifier: Programming Language :: Python :: Implementation :: Jython
|
||||
Classifier: Programming Language :: Python :: Implementation :: IronPython
|
||||
Classifier: Topic :: Software Development :: Libraries
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Classifier: Topic :: System :: Logging
|
||||
Description-Content-Type: text/markdown
|
||||
|
||||
# Autologging - easier logging and tracing for Python classes
|
||||
|
||||
http://ninthtest.info/python-autologging/
|
||||
|
||||
[](https://pypi.python.org/pypi/Autologging)
|
||||
[](https://pypi.python.org/pypi/Autologging)
|
||||
[](https://pypi.python.org/pypi/Autologging)
|
||||
[](https://github.com/mzipay/Autologging/blob/master/LICENSE.txt)
|
||||
[](https://pypi.python.org/pypi/Autologging)
|
||||
|
||||
## Introduction
|
||||
|
||||
Autologging eliminates boilerplate logging setup code and tracing code,
|
||||
and provides a means to separate application logging from program flow
|
||||
and data tracing.
|
||||
|
||||
Python modules that make use of Autologging are cleaner, leaner, and
|
||||
more resilient to changes that would otherwise require updating tracing
|
||||
statements.
|
||||
|
||||
Autologging allows for tracing to be configured (and controlled)
|
||||
independently from application logging. Toggle tracing on/off, write
|
||||
trace log records to a separate log, and use different formatting for
|
||||
trace log entries - all via standard Python logging facilities, and
|
||||
without affecting your application logging.
|
||||
|
||||
### What's in the `autologging` namespace?
|
||||
|
||||
Autologging exposes two decorators and a custom log level:
|
||||
|
||||
**`logged`**
|
||||
Decorate a class to create a `__log` member. The logger is named by
|
||||
default to match the dotted-name of the containing class. A function
|
||||
may also be decorated, creating a `_log` attribute on the function
|
||||
object whose default name matches the containing module.
|
||||
A specifically-named logger may also be passed to the decorator (i.e.
|
||||
`logged(my_logger)`).
|
||||
|
||||
**`traced`**
|
||||
Decorate a class to provide **automatic** method call/return tracing. By
|
||||
default, all class, static, and instance methods are traced (excluding
|
||||
"__special__" methods, with the exception of `__init__` and `__call__`).
|
||||
As with the `logged` decorator, the default name of the tracing logger
|
||||
matches the dotted-name of the containing class and may be overridden by
|
||||
passing a specifically-named logger to the decorator.
|
||||
Additionally, this decorator accepts multiple string arguments that
|
||||
explicitly name the methods to be traced (and may even name
|
||||
"__special__" methods).
|
||||
|
||||
Module-level functions may also be traced using this decorator.
|
||||
|
||||
*New in version 1.2.0:* automatic yield/stop tracing of Python
|
||||
[generator iterators](https://docs.python.org/3/glossary.html#term-generator-iterator)
|
||||
(if the [generator](https://docs.python.org/3/glossary.html#term-generator)
|
||||
function is traced).
|
||||
|
||||
**`TRACE`**
|
||||
The `autologging.TRACE` (level 1) log level is registered with the
|
||||
Python `logging` module when Autologging is imported so that tracing
|
||||
can be configured and controlled independently of application logging.
|
||||
|
||||
Tracing may be disabled entirely by setting the
|
||||
`AUTOLOGGING_TRACED_NOOP` environment variable or by calling the
|
||||
`autologging.install_traced_noop()` function.
|
||||
|
||||
## A brief example
|
||||
|
||||
A simple logged and traced class:
|
||||
|
||||
```python
|
||||
1 import logging
|
||||
2 import sys
|
||||
3
|
||||
4 from autologging import logged, TRACE, traced
|
||||
5
|
||||
6 @traced
|
||||
7 @logged
|
||||
8 class Example:
|
||||
9
|
||||
10 def __init__(self):
|
||||
11 self.__log.info("initialized")
|
||||
12
|
||||
13 def backwards(self, *words):
|
||||
14 for word in words:
|
||||
15 yield "".join(reversed(word))
|
||||
16
|
||||
17
|
||||
18 if __name__ == "__main__":
|
||||
19 logging.basicConfig(
|
||||
20 level=TRACE, stream=sys.stderr,
|
||||
21 format="%(levelname)s:%(filename)s,%(lineno)d:%(name)s.%(funcName)s:%(message)s")
|
||||
22 example = Example()
|
||||
23 for result in example.backwards("spam", "eggs"):
|
||||
24 print(result)
|
||||
```
|
||||
|
||||
Logging and tracing output:
|
||||
|
||||
```bash
|
||||
$ python example.py
|
||||
TRACE:example.py,10:__main__.Example.__init__:CALL *() **{}
|
||||
INFO:example.py,11:__main__.Example.__init__:initialized
|
||||
TRACE:example.py,11:__main__.Example.__init__:RETURN None
|
||||
TRACE:example.py,13:__main__.Example.backwards:CALL *('spam', 'eggs') **{}
|
||||
TRACE:example.py,15:__main__.Example.backwards:RETURN <generator object backwards at 0x7fa534d61eb0>
|
||||
TRACE:example.py,15:__main__.Example.backwards:YIELD 'maps'
|
||||
maps
|
||||
TRACE:example.py,15:__main__.Example.backwards:YIELD 'sgge'
|
||||
sgge
|
||||
TRACE:example.py,15:__main__.Example.backwards:STOP
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
The easiest way to install Autologging is to use
|
||||
[pip](https://pip.pypa.io/):
|
||||
|
||||
```bash
|
||||
$ pip install Autologging
|
||||
```
|
||||
|
||||
### Source installation
|
||||
|
||||
Clone or fork the repository:
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/mzipay/Autologging.git
|
||||
```
|
||||
|
||||
Alternatively, download and extract a source .zip or .tar.gz archive
|
||||
from https://github.com/mzipay/Autologging/releases,
|
||||
https://pypi.python.org/pypi/Autologging or
|
||||
https://sourceforge.net/projects/autologging/files/.
|
||||
|
||||
Run the test suite and install the `autologging` module: (make sure you
|
||||
have [setuptools](https://pypi.python.org/pypi/setuptools) installed!)
|
||||
|
||||
```bash
|
||||
$ cd Autologging
|
||||
$ python setup.py test
|
||||
$ python setup.py install
|
||||
```
|
||||
|
||||
### Binary installation
|
||||
|
||||
Download the Python wheel (.whl) or a Windows installer from
|
||||
https://pypi.python.org/pypi/Autologging or
|
||||
https://sourceforge.net/projects/autologging/files/.
|
||||
|
||||
(Use [pip](https://pip.pypa.io/) or
|
||||
[wheel](https://pypi.python.org/pypi/wheel) to install the .whl.)
|
||||
|
||||
|
||||
|
||||
7
APPS/lib/Autologging-1.3.2.dist-info/RECORD
Normal file
7
APPS/lib/Autologging-1.3.2.dist-info/RECORD
Normal file
@@ -0,0 +1,7 @@
|
||||
Autologging-1.3.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
Autologging-1.3.2.dist-info/METADATA,sha256=QGa3W8evYsoGG9bHIo9ScNopJ1uecjO_AQL4bWKX-ZQ,6900
|
||||
Autologging-1.3.2.dist-info/RECORD,,
|
||||
Autologging-1.3.2.dist-info/WHEEL,sha256=gduuPyBvFJQSQ0zdyxF7k0zynDXbIbvg5ZBHoXum5uk,110
|
||||
Autologging-1.3.2.dist-info/top_level.txt,sha256=B-vyHWUjgzhtxF6_6Zu78hcLHmpuxF6n1gxIDuejIw4,12
|
||||
__pycache__/autologging.cpython-37.pyc,,
|
||||
autologging.py,sha256=n0t_9DpqUKCmPOFJ_zx99DwJ0znouWRNZjUe1rIxfew,47165
|
||||
6
APPS/lib/Autologging-1.3.2.dist-info/WHEEL
Normal file
6
APPS/lib/Autologging-1.3.2.dist-info/WHEEL
Normal file
@@ -0,0 +1,6 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.31.1)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
1
APPS/lib/Autologging-1.3.2.dist-info/top_level.txt
Normal file
1
APPS/lib/Autologging-1.3.2.dist-info/top_level.txt
Normal file
@@ -0,0 +1 @@
|
||||
autologging
|
||||
115
APPS/lib/Crypto/Cipher/AES.py
Normal file
115
APPS/lib/Crypto/Cipher/AES.py
Normal file
@@ -0,0 +1,115 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/AES.py : AES
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""AES symmetric cipher
|
||||
|
||||
AES `(Advanced Encryption Standard)`__ is a symmetric block cipher standardized
|
||||
by NIST_ . It has a fixed data block size of 16 bytes.
|
||||
Its keys can be 128, 192, or 256 bits long.
|
||||
|
||||
AES is very fast and secure, and it is the de facto standard for symmetric
|
||||
encryption.
|
||||
|
||||
As an example, encryption can be done as follows:
|
||||
|
||||
>>> from Crypto.Cipher import AES
|
||||
>>> from Crypto import Random
|
||||
>>>
|
||||
>>> key = b'Sixteen byte key'
|
||||
>>> iv = Random.new().read(AES.block_size)
|
||||
>>> cipher = AES.new(key, AES.MODE_CFB, iv)
|
||||
>>> msg = iv + cipher.encrypt(b'Attack at dawn')
|
||||
|
||||
.. __: http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
|
||||
.. _NIST: http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import blockalgo
|
||||
from Crypto.Cipher import _AES
|
||||
|
||||
class AESCipher (blockalgo.BlockAlgo):
|
||||
"""AES cipher object"""
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize an AES cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new AES cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
It must be 16 (*AES-128*), 24 (*AES-192*), or 32 (*AES-256*) bytes long.
|
||||
:Keywords:
|
||||
mode : a *MODE_** constant
|
||||
The chaining mode to use for encryption or decryption.
|
||||
Default is `MODE_ECB`.
|
||||
IV : byte string
|
||||
The initialization vector to use for encryption or decryption.
|
||||
|
||||
It is ignored for `MODE_ECB` and `MODE_CTR`.
|
||||
|
||||
For `MODE_OPENPGP`, IV must be `block_size` bytes long for encryption
|
||||
and `block_size` +2 bytes for decryption (in the latter case, it is
|
||||
actually the *encrypted* IV which was prefixed to the ciphertext).
|
||||
It is mandatory.
|
||||
|
||||
For all other modes, it must be `block_size` bytes longs. It is optional and
|
||||
when not present it will be given a default value of all zeroes.
|
||||
counter : callable
|
||||
(*Only* `MODE_CTR`). A stateful function that returns the next
|
||||
*counter block*, which is a byte string of `block_size` bytes.
|
||||
For better performance, use `Crypto.Util.Counter`.
|
||||
segment_size : integer
|
||||
(*Only* `MODE_CFB`).The number of bits the plaintext and ciphertext
|
||||
are segmented in.
|
||||
It must be a multiple of 8. If 0 or not specified, it will be assumed to be 8.
|
||||
|
||||
:Return: an `AESCipher` object
|
||||
"""
|
||||
return AESCipher(key, *args, **kwargs)
|
||||
|
||||
#: Electronic Code Book (ECB). See `blockalgo.MODE_ECB`.
|
||||
MODE_ECB = 1
|
||||
#: Cipher-Block Chaining (CBC). See `blockalgo.MODE_CBC`.
|
||||
MODE_CBC = 2
|
||||
#: Cipher FeedBack (CFB). See `blockalgo.MODE_CFB`.
|
||||
MODE_CFB = 3
|
||||
#: This mode should not be used.
|
||||
MODE_PGP = 4
|
||||
#: Output FeedBack (OFB). See `blockalgo.MODE_OFB`.
|
||||
MODE_OFB = 5
|
||||
#: CounTer Mode (CTR). See `blockalgo.MODE_CTR`.
|
||||
MODE_CTR = 6
|
||||
#: OpenPGP Mode. See `blockalgo.MODE_OPENPGP`.
|
||||
MODE_OPENPGP = 7
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 16
|
||||
#: Size of a key (in bytes)
|
||||
key_size = ( 16, 24, 32 )
|
||||
|
||||
130
APPS/lib/Crypto/Cipher/ARC2.py
Normal file
130
APPS/lib/Crypto/Cipher/ARC2.py
Normal file
@@ -0,0 +1,130 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/ARC2.py : ARC2.py
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""RC2 symmetric cipher
|
||||
|
||||
RC2_ (Rivest's Cipher version 2) is a symmetric block cipher designed
|
||||
by Ron Rivest in 1987. The cipher started as a proprietary design,
|
||||
that was reverse engineered and anonymously posted on Usenet in 1996.
|
||||
For this reason, the algorithm was first called *Alleged* RC2 (ARC2),
|
||||
since the company that owned RC2 (RSA Data Inc.) did not confirm whether
|
||||
the details leaked into public domain were really correct.
|
||||
|
||||
The company eventually published its full specification in RFC2268_.
|
||||
|
||||
RC2 has a fixed data block size of 8 bytes. Length of its keys can vary from
|
||||
8 to 128 bits. One particular property of RC2 is that the actual
|
||||
cryptographic strength of the key (*effective key length*) can be reduced
|
||||
via a parameter.
|
||||
|
||||
Even though RC2 is not cryptographically broken, it has not been analyzed as
|
||||
thoroughly as AES, which is also faster than RC2.
|
||||
|
||||
New designs should not use RC2.
|
||||
|
||||
As an example, encryption can be done as follows:
|
||||
|
||||
>>> from Crypto.Cipher import ARC2
|
||||
>>> from Crypto import Random
|
||||
>>>
|
||||
>>> key = b'Sixteen byte key'
|
||||
>>> iv = Random.new().read(ARC2.block_size)
|
||||
>>> cipher = ARC2.new(key, ARC2.MODE_CFB, iv)
|
||||
>>> msg = iv + cipher.encrypt(b'Attack at dawn')
|
||||
|
||||
.. _RC2: http://en.wikipedia.org/wiki/RC2
|
||||
.. _RFC2268: http://tools.ietf.org/html/rfc2268
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import blockalgo
|
||||
from Crypto.Cipher import _ARC2
|
||||
|
||||
class RC2Cipher (blockalgo.BlockAlgo):
|
||||
"""RC2 cipher object"""
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize an ARC2 cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
blockalgo.BlockAlgo.__init__(self, _ARC2, key, *args, **kwargs)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new RC2 cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
Its length can vary from 1 to 128 bytes.
|
||||
:Keywords:
|
||||
mode : a *MODE_** constant
|
||||
The chaining mode to use for encryption or decryption.
|
||||
Default is `MODE_ECB`.
|
||||
IV : byte string
|
||||
The initialization vector to use for encryption or decryption.
|
||||
|
||||
It is ignored for `MODE_ECB` and `MODE_CTR`.
|
||||
|
||||
For `MODE_OPENPGP`, IV must be `block_size` bytes long for encryption
|
||||
and `block_size` +2 bytes for decryption (in the latter case, it is
|
||||
actually the *encrypted* IV which was prefixed to the ciphertext).
|
||||
It is mandatory.
|
||||
|
||||
For all other modes, it must be `block_size` bytes longs. It is optional and
|
||||
when not present it will be given a default value of all zeroes.
|
||||
counter : callable
|
||||
(*Only* `MODE_CTR`). A stateful function that returns the next
|
||||
*counter block*, which is a byte string of `block_size` bytes.
|
||||
For better performance, use `Crypto.Util.Counter`.
|
||||
segment_size : integer
|
||||
(*Only* `MODE_CFB`).The number of bits the plaintext and ciphertext
|
||||
are segmented in.
|
||||
It must be a multiple of 8. If 0 or not specified, it will be assumed to be 8.
|
||||
effective_keylen : integer
|
||||
Maximum cryptographic strength of the key, in bits.
|
||||
It can vary from 0 to 1024. The default value is 1024.
|
||||
|
||||
:Return: an `RC2Cipher` object
|
||||
"""
|
||||
return RC2Cipher(key, *args, **kwargs)
|
||||
|
||||
#: Electronic Code Book (ECB). See `blockalgo.MODE_ECB`.
|
||||
MODE_ECB = 1
|
||||
#: Cipher-Block Chaining (CBC). See `blockalgo.MODE_CBC`.
|
||||
MODE_CBC = 2
|
||||
#: Cipher FeedBack (CFB). See `blockalgo.MODE_CFB`.
|
||||
MODE_CFB = 3
|
||||
#: This mode should not be used.
|
||||
MODE_PGP = 4
|
||||
#: Output FeedBack (OFB). See `blockalgo.MODE_OFB`.
|
||||
MODE_OFB = 5
|
||||
#: CounTer Mode (CTR). See `blockalgo.MODE_CTR`.
|
||||
MODE_CTR = 6
|
||||
#: OpenPGP Mode. See `blockalgo.MODE_OPENPGP`.
|
||||
MODE_OPENPGP = 7
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 8
|
||||
#: Size of a key (in bytes)
|
||||
key_size = range(1,16+1)
|
||||
|
||||
120
APPS/lib/Crypto/Cipher/ARC4.py
Normal file
120
APPS/lib/Crypto/Cipher/ARC4.py
Normal file
@@ -0,0 +1,120 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/ARC4.py : ARC4
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""ARC4 symmetric cipher
|
||||
|
||||
ARC4_ (Alleged RC4) is an implementation of RC4 (Rivest's Cipher version 4),
|
||||
a symmetric stream cipher designed by Ron Rivest in 1987.
|
||||
|
||||
The cipher started as a proprietary design, that was reverse engineered and
|
||||
anonymously posted on Usenet in 1994. The company that owns RC4 (RSA Data
|
||||
Inc.) never confirmed the correctness of the leaked algorithm.
|
||||
|
||||
Unlike RC2, the company has never published the full specification of RC4,
|
||||
of whom it still holds the trademark.
|
||||
|
||||
ARC4 keys can vary in length from 40 to 2048 bits.
|
||||
|
||||
One problem of ARC4 is that it does not take a nonce or an IV. If it is required
|
||||
to encrypt multiple messages with the same long-term key, a distinct
|
||||
independent nonce must be created for each message, and a short-term key must
|
||||
be derived from the combination of the long-term key and the nonce.
|
||||
Due to the weak key scheduling algorithm of RC2, the combination must be carried
|
||||
out with a complex function (e.g. a cryptographic hash) and not by simply
|
||||
concatenating key and nonce.
|
||||
|
||||
New designs should not use ARC4. A good alternative is AES
|
||||
(`Crypto.Cipher.AES`) in any of the modes that turn it into a stream cipher (OFB, CFB, or CTR).
|
||||
|
||||
As an example, encryption can be done as follows:
|
||||
|
||||
>>> from Crypto.Cipher import ARC4
|
||||
>>> from Crypto.Hash import SHA
|
||||
>>> from Crypto import Random
|
||||
>>>
|
||||
>>> key = b'Very long and confidential key'
|
||||
>>> nonce = Random.new().read(16)
|
||||
>>> tempkey = SHA.new(key+nonce).digest()
|
||||
>>> cipher = ARC4.new(tempkey)
|
||||
>>> msg = nonce + cipher.encrypt(b'Open the pod bay doors, HAL')
|
||||
|
||||
.. _ARC4: http://en.wikipedia.org/wiki/RC4
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import _ARC4
|
||||
|
||||
class ARC4Cipher:
|
||||
"""ARC4 cipher object"""
|
||||
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize an ARC4 cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
|
||||
self._cipher = _ARC4.new(key, *args, **kwargs)
|
||||
self.block_size = self._cipher.block_size
|
||||
self.key_size = self._cipher.key_size
|
||||
|
||||
def encrypt(self, plaintext):
|
||||
"""Encrypt a piece of data.
|
||||
|
||||
:Parameters:
|
||||
plaintext : byte string
|
||||
The piece of data to encrypt. It can be of any size.
|
||||
:Return: the encrypted data (byte string, as long as the
|
||||
plaintext).
|
||||
"""
|
||||
return self._cipher.encrypt(plaintext)
|
||||
|
||||
def decrypt(self, ciphertext):
|
||||
"""Decrypt a piece of data.
|
||||
|
||||
:Parameters:
|
||||
ciphertext : byte string
|
||||
The piece of data to decrypt. It can be of any size.
|
||||
:Return: the decrypted data (byte string, as long as the
|
||||
ciphertext).
|
||||
"""
|
||||
return self._cipher.decrypt(ciphertext)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new ARC4 cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
It can have any length, with a minimum of 40 bytes.
|
||||
Its cryptograpic strength is always capped to 2048 bits (256 bytes).
|
||||
|
||||
:Return: an `ARC4Cipher` object
|
||||
"""
|
||||
return ARC4Cipher(key, *args, **kwargs)
|
||||
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 1
|
||||
#: Size of a key (in bytes)
|
||||
key_size = range(1,256+1)
|
||||
|
||||
121
APPS/lib/Crypto/Cipher/Blowfish.py
Normal file
121
APPS/lib/Crypto/Cipher/Blowfish.py
Normal file
@@ -0,0 +1,121 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/Blowfish.py : Blowfish
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""Blowfish symmetric cipher
|
||||
|
||||
Blowfish_ is a symmetric block cipher designed by Bruce Schneier.
|
||||
|
||||
It has a fixed data block size of 8 bytes and its keys can vary in length
|
||||
from 32 to 448 bits (4 to 56 bytes).
|
||||
|
||||
Blowfish is deemed secure and it is fast. However, its keys should be chosen
|
||||
to be big enough to withstand a brute force attack (e.g. at least 16 bytes).
|
||||
|
||||
As an example, encryption can be done as follows:
|
||||
|
||||
>>> from Crypto.Cipher import Blowfish
|
||||
>>> from Crypto import Random
|
||||
>>> from struct import pack
|
||||
>>>
|
||||
>>> bs = Blowfish.block_size
|
||||
>>> key = b'An arbitrarily long key'
|
||||
>>> iv = Random.new().read(bs)
|
||||
>>> cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)
|
||||
>>> plaintext = b'docendo discimus '
|
||||
>>> plen = bs - divmod(len(plaintext),bs)[1]
|
||||
>>> padding = [plen]*plen
|
||||
>>> padding = pack('b'*plen, *padding)
|
||||
>>> msg = iv + cipher.encrypt(plaintext + padding)
|
||||
|
||||
.. _Blowfish: http://www.schneier.com/blowfish.html
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import blockalgo
|
||||
from Crypto.Cipher import _Blowfish
|
||||
|
||||
class BlowfishCipher (blockalgo.BlockAlgo):
|
||||
"""Blowfish cipher object"""
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize a Blowfish cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
blockalgo.BlockAlgo.__init__(self, _Blowfish, key, *args, **kwargs)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new Blowfish cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
Its length can vary from 4 to 56 bytes.
|
||||
:Keywords:
|
||||
mode : a *MODE_** constant
|
||||
The chaining mode to use for encryption or decryption.
|
||||
Default is `MODE_ECB`.
|
||||
IV : byte string
|
||||
The initialization vector to use for encryption or decryption.
|
||||
|
||||
It is ignored for `MODE_ECB` and `MODE_CTR`.
|
||||
|
||||
For `MODE_OPENPGP`, IV must be `block_size` bytes long for encryption
|
||||
and `block_size` +2 bytes for decryption (in the latter case, it is
|
||||
actually the *encrypted* IV which was prefixed to the ciphertext).
|
||||
It is mandatory.
|
||||
|
||||
For all other modes, it must be `block_size` bytes longs. It is optional and
|
||||
when not present it will be given a default value of all zeroes.
|
||||
counter : callable
|
||||
(*Only* `MODE_CTR`). A stateful function that returns the next
|
||||
*counter block*, which is a byte string of `block_size` bytes.
|
||||
For better performance, use `Crypto.Util.Counter`.
|
||||
segment_size : integer
|
||||
(*Only* `MODE_CFB`).The number of bits the plaintext and ciphertext
|
||||
are segmented in.
|
||||
It must be a multiple of 8. If 0 or not specified, it will be assumed to be 8.
|
||||
|
||||
:Return: a `BlowfishCipher` object
|
||||
"""
|
||||
return BlowfishCipher(key, *args, **kwargs)
|
||||
|
||||
#: Electronic Code Book (ECB). See `blockalgo.MODE_ECB`.
|
||||
MODE_ECB = 1
|
||||
#: Cipher-Block Chaining (CBC). See `blockalgo.MODE_CBC`.
|
||||
MODE_CBC = 2
|
||||
#: Cipher FeedBack (CFB). See `blockalgo.MODE_CFB`.
|
||||
MODE_CFB = 3
|
||||
#: This mode should not be used.
|
||||
MODE_PGP = 4
|
||||
#: Output FeedBack (OFB). See `blockalgo.MODE_OFB`.
|
||||
MODE_OFB = 5
|
||||
#: CounTer Mode (CTR). See `blockalgo.MODE_CTR`.
|
||||
MODE_CTR = 6
|
||||
#: OpenPGP Mode. See `blockalgo.MODE_OPENPGP`.
|
||||
MODE_OPENPGP = 7
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 8
|
||||
#: Size of a key (in bytes)
|
||||
key_size = range(4,56+1)
|
||||
|
||||
123
APPS/lib/Crypto/Cipher/CAST.py
Normal file
123
APPS/lib/Crypto/Cipher/CAST.py
Normal file
@@ -0,0 +1,123 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/CAST.py : CAST
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""CAST-128 symmetric cipher
|
||||
|
||||
CAST-128_ (or CAST5) is a symmetric block cipher specified in RFC2144_.
|
||||
|
||||
It has a fixed data block size of 8 bytes. Its key can vary in length
|
||||
from 40 to 128 bits.
|
||||
|
||||
CAST is deemed to be cryptographically secure, but its usage is not widespread.
|
||||
Keys of sufficient length should be used to prevent brute force attacks
|
||||
(128 bits are recommended).
|
||||
|
||||
As an example, encryption can be done as follows:
|
||||
|
||||
>>> from Crypto.Cipher import CAST
|
||||
>>> from Crypto import Random
|
||||
>>>
|
||||
>>> key = b'Sixteen byte key'
|
||||
>>> iv = Random.new().read(CAST.block_size)
|
||||
>>> cipher = CAST.new(key, CAST.MODE_OPENPGP, iv)
|
||||
>>> plaintext = b'sona si latine loqueris '
|
||||
>>> msg = cipher.encrypt(plaintext)
|
||||
>>>
|
||||
...
|
||||
>>> eiv = msg[:CAST.block_size+2]
|
||||
>>> ciphertext = msg[CAST.block_size+2:]
|
||||
>>> cipher = CAST.new(key, CAST.MODE_OPENPGP, eiv)
|
||||
>>> print cipher.decrypt(ciphertext)
|
||||
|
||||
.. _CAST-128: http://en.wikipedia.org/wiki/CAST-128
|
||||
.. _RFC2144: http://tools.ietf.org/html/rfc2144
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import blockalgo
|
||||
from Crypto.Cipher import _CAST
|
||||
|
||||
class CAST128Cipher(blockalgo.BlockAlgo):
|
||||
"""CAST-128 cipher object"""
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize a CAST-128 cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
blockalgo.BlockAlgo.__init__(self, _CAST, key, *args, **kwargs)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new CAST-128 cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
Its length may vary from 5 to 16 bytes.
|
||||
:Keywords:
|
||||
mode : a *MODE_** constant
|
||||
The chaining mode to use for encryption or decryption.
|
||||
Default is `MODE_ECB`.
|
||||
IV : byte string
|
||||
The initialization vector to use for encryption or decryption.
|
||||
|
||||
It is ignored for `MODE_ECB` and `MODE_CTR`.
|
||||
|
||||
For `MODE_OPENPGP`, IV must be `block_size` bytes long for encryption
|
||||
and `block_size` +2 bytes for decryption (in the latter case, it is
|
||||
actually the *encrypted* IV which was prefixed to the ciphertext).
|
||||
It is mandatory.
|
||||
|
||||
For all other modes, it must be `block_size` bytes longs. It is optional and
|
||||
when not present it will be given a default value of all zeroes.
|
||||
counter : callable
|
||||
(*Only* `MODE_CTR`). A stateful function that returns the next
|
||||
*counter block*, which is a byte string of `block_size` bytes.
|
||||
For better performance, use `Crypto.Util.Counter`.
|
||||
segment_size : integer
|
||||
(*Only* `MODE_CFB`).The number of bits the plaintext and ciphertext
|
||||
are segmented in.
|
||||
It must be a multiple of 8. If 0 or not specified, it will be assumed to be 8.
|
||||
|
||||
:Return: an `CAST128Cipher` object
|
||||
"""
|
||||
return CAST128Cipher(key, *args, **kwargs)
|
||||
|
||||
#: Electronic Code Book (ECB). See `blockalgo.MODE_ECB`.
|
||||
MODE_ECB = 1
|
||||
#: Cipher-Block Chaining (CBC). See `blockalgo.MODE_CBC`.
|
||||
MODE_CBC = 2
|
||||
#: Cipher FeedBack (CFB). See `blockalgo.MODE_CFB`.
|
||||
MODE_CFB = 3
|
||||
#: This mode should not be used.
|
||||
MODE_PGP = 4
|
||||
#: Output FeedBack (OFB). See `blockalgo.MODE_OFB`.
|
||||
MODE_OFB = 5
|
||||
#: CounTer Mode (CTR). See `blockalgo.MODE_CTR`.
|
||||
MODE_CTR = 6
|
||||
#: OpenPGP Mode. See `blockalgo.MODE_OPENPGP`.
|
||||
MODE_OPENPGP = 7
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 8
|
||||
#: Size of a key (in bytes)
|
||||
key_size = range(5,16+1)
|
||||
118
APPS/lib/Crypto/Cipher/DES.py
Normal file
118
APPS/lib/Crypto/Cipher/DES.py
Normal file
@@ -0,0 +1,118 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/DES.py : DES
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""DES symmetric cipher
|
||||
|
||||
DES `(Data Encryption Standard)`__ is a symmetric block cipher standardized
|
||||
by NIST_ . It has a fixed data block size of 8 bytes.
|
||||
Its keys are 64 bits long, even though 8 bits were used for integrity (now they
|
||||
are ignored) and do not contribute to securty.
|
||||
|
||||
DES is cryptographically secure, but its key length is too short by nowadays
|
||||
standards and it could be brute forced with some effort.
|
||||
|
||||
DES should not be used for new designs. Use `AES`.
|
||||
|
||||
As an example, encryption can be done as follows:
|
||||
|
||||
>>> from Crypto.Cipher import DES3
|
||||
>>> from Crypto import Random
|
||||
>>>
|
||||
>>> key = b'Sixteen byte key'
|
||||
>>> iv = Random.new().read(DES3.block_size)
|
||||
>>> cipher = DES3.new(key, DES3.MODE_OFB, iv)
|
||||
>>> plaintext = b'sona si latine loqueris '
|
||||
>>> msg = iv + cipher.encrypt(plaintext)
|
||||
|
||||
.. __: http://en.wikipedia.org/wiki/Data_Encryption_Standard
|
||||
.. _NIST: http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import blockalgo
|
||||
from Crypto.Cipher import _DES
|
||||
|
||||
class DESCipher(blockalgo.BlockAlgo):
|
||||
"""DES cipher object"""
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize a DES cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
blockalgo.BlockAlgo.__init__(self, _DES, key, *args, **kwargs)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new DES cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
It must be 8 byte long. The parity bits will be ignored.
|
||||
:Keywords:
|
||||
mode : a *MODE_** constant
|
||||
The chaining mode to use for encryption or decryption.
|
||||
Default is `MODE_ECB`.
|
||||
IV : byte string
|
||||
The initialization vector to use for encryption or decryption.
|
||||
|
||||
It is ignored for `MODE_ECB` and `MODE_CTR`.
|
||||
|
||||
For `MODE_OPENPGP`, IV must be `block_size` bytes long for encryption
|
||||
and `block_size` +2 bytes for decryption (in the latter case, it is
|
||||
actually the *encrypted* IV which was prefixed to the ciphertext).
|
||||
It is mandatory.
|
||||
|
||||
For all other modes, it must be `block_size` bytes longs. It is optional and
|
||||
when not present it will be given a default value of all zeroes.
|
||||
counter : callable
|
||||
(*Only* `MODE_CTR`). A stateful function that returns the next
|
||||
*counter block*, which is a byte string of `block_size` bytes.
|
||||
For better performance, use `Crypto.Util.Counter`.
|
||||
segment_size : integer
|
||||
(*Only* `MODE_CFB`).The number of bits the plaintext and ciphertext
|
||||
are segmented in.
|
||||
It must be a multiple of 8. If 0 or not specified, it will be assumed to be 8.
|
||||
|
||||
:Return: an `DESCipher` object
|
||||
"""
|
||||
return DESCipher(key, *args, **kwargs)
|
||||
|
||||
#: Electronic Code Book (ECB). See `blockalgo.MODE_ECB`.
|
||||
MODE_ECB = 1
|
||||
#: Cipher-Block Chaining (CBC). See `blockalgo.MODE_CBC`.
|
||||
MODE_CBC = 2
|
||||
#: Cipher FeedBack (CFB). See `blockalgo.MODE_CFB`.
|
||||
MODE_CFB = 3
|
||||
#: This mode should not be used.
|
||||
MODE_PGP = 4
|
||||
#: Output FeedBack (OFB). See `blockalgo.MODE_OFB`.
|
||||
MODE_OFB = 5
|
||||
#: CounTer Mode (CTR). See `blockalgo.MODE_CTR`.
|
||||
MODE_CTR = 6
|
||||
#: OpenPGP Mode. See `blockalgo.MODE_OPENPGP`.
|
||||
MODE_OPENPGP = 7
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 8
|
||||
#: Size of a key (in bytes)
|
||||
key_size = 8
|
||||
133
APPS/lib/Crypto/Cipher/DES3.py
Normal file
133
APPS/lib/Crypto/Cipher/DES3.py
Normal file
@@ -0,0 +1,133 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/DES3.py : DES3
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""Triple DES symmetric cipher
|
||||
|
||||
`Triple DES`__ (or TDES or TDEA or 3DES) is a symmetric block cipher standardized by NIST_.
|
||||
It has a fixed data block size of 8 bytes. Its keys are 128 (*Option 1*) or 192
|
||||
bits (*Option 2*) long.
|
||||
However, 1 out of 8 bits is used for redundancy and do not contribute to
|
||||
security. The effective key length is respectively 112 or 168 bits.
|
||||
|
||||
TDES consists of the concatenation of 3 simple `DES` ciphers.
|
||||
|
||||
The plaintext is first DES encrypted with *K1*, then decrypted with *K2*,
|
||||
and finally encrypted again with *K3*. The ciphertext is decrypted in the reverse manner.
|
||||
|
||||
The 192 bit key is a bundle of three 64 bit independent subkeys: *K1*, *K2*, and *K3*.
|
||||
|
||||
The 128 bit key is split into *K1* and *K2*, whereas *K1=K3*.
|
||||
|
||||
It is important that all subkeys are different, otherwise TDES would degrade to
|
||||
single `DES`.
|
||||
|
||||
TDES is cryptographically secure, even though it is neither as secure nor as fast
|
||||
as `AES`.
|
||||
|
||||
As an example, encryption can be done as follows:
|
||||
|
||||
>>> from Crypto.Cipher import DES
|
||||
>>> from Crypto import Random
|
||||
>>> from Crypto.Util import Counter
|
||||
>>>
|
||||
>>> key = b'-8B key-'
|
||||
>>> nonce = Random.new().read(DES.block_size/2)
|
||||
>>> ctr = Counter.new(DES.block_size*8/2, prefix=nonce)
|
||||
>>> cipher = DES.new(key, DES.MODE_CTR, counter=ctr)
|
||||
>>> plaintext = b'We are no longer the knights who say ni!'
|
||||
>>> msg = nonce + cipher.encrypt(plaintext)
|
||||
|
||||
.. __: http://en.wikipedia.org/wiki/Triple_DES
|
||||
.. _NIST: http://csrc.nist.gov/publications/nistpubs/800-67/SP800-67.pdf
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import blockalgo
|
||||
from Crypto.Cipher import _DES3
|
||||
|
||||
class DES3Cipher(blockalgo.BlockAlgo):
|
||||
"""TDES cipher object"""
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize a TDES cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
blockalgo.BlockAlgo.__init__(self, _DES3, key, *args, **kwargs)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new TDES cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
It must be 16 or 24 bytes long. The parity bits will be ignored.
|
||||
:Keywords:
|
||||
mode : a *MODE_** constant
|
||||
The chaining mode to use for encryption or decryption.
|
||||
Default is `MODE_ECB`.
|
||||
IV : byte string
|
||||
The initialization vector to use for encryption or decryption.
|
||||
|
||||
It is ignored for `MODE_ECB` and `MODE_CTR`.
|
||||
|
||||
For `MODE_OPENPGP`, IV must be `block_size` bytes long for encryption
|
||||
and `block_size` +2 bytes for decryption (in the latter case, it is
|
||||
actually the *encrypted* IV which was prefixed to the ciphertext).
|
||||
It is mandatory.
|
||||
|
||||
For all other modes, it must be `block_size` bytes longs. It is optional and
|
||||
when not present it will be given a default value of all zeroes.
|
||||
counter : callable
|
||||
(*Only* `MODE_CTR`). A stateful function that returns the next
|
||||
*counter block*, which is a byte string of `block_size` bytes.
|
||||
For better performance, use `Crypto.Util.Counter`.
|
||||
segment_size : integer
|
||||
(*Only* `MODE_CFB`).The number of bits the plaintext and ciphertext
|
||||
are segmented in.
|
||||
It must be a multiple of 8. If 0 or not specified, it will be assumed to be 8.
|
||||
|
||||
:Attention: it is important that all 8 byte subkeys are different,
|
||||
otherwise TDES would degrade to single `DES`.
|
||||
:Return: an `DES3Cipher` object
|
||||
"""
|
||||
return DES3Cipher(key, *args, **kwargs)
|
||||
|
||||
#: Electronic Code Book (ECB). See `blockalgo.MODE_ECB`.
|
||||
MODE_ECB = 1
|
||||
#: Cipher-Block Chaining (CBC). See `blockalgo.MODE_CBC`.
|
||||
MODE_CBC = 2
|
||||
#: Cipher FeedBack (CFB). See `blockalgo.MODE_CFB`.
|
||||
MODE_CFB = 3
|
||||
#: This mode should not be used.
|
||||
MODE_PGP = 4
|
||||
#: Output FeedBack (OFB). See `blockalgo.MODE_OFB`.
|
||||
MODE_OFB = 5
|
||||
#: CounTer Mode (CTR). See `blockalgo.MODE_CTR`.
|
||||
MODE_CTR = 6
|
||||
#: OpenPGP Mode. See `blockalgo.MODE_OPENPGP`.
|
||||
MODE_OPENPGP = 7
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 8
|
||||
#: Size of a key (in bytes)
|
||||
key_size = ( 16, 24 )
|
||||
255
APPS/lib/Crypto/Cipher/PKCS1_OAEP.py
Normal file
255
APPS/lib/Crypto/Cipher/PKCS1_OAEP.py
Normal file
@@ -0,0 +1,255 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/PKCS1_OAEP.py : PKCS#1 OAEP
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
|
||||
"""RSA encryption protocol according to PKCS#1 OAEP
|
||||
|
||||
See RFC3447__ or the `original RSA Labs specification`__ .
|
||||
|
||||
This scheme is more properly called ``RSAES-OAEP``.
|
||||
|
||||
As an example, a sender may encrypt a message in this way:
|
||||
|
||||
>>> from Crypto.Cipher import PKCS1_OAEP
|
||||
>>> from Crypto.PublicKey import RSA
|
||||
>>>
|
||||
>>> message = 'To be encrypted'
|
||||
>>> key = RSA.importKey(open('pubkey.der').read())
|
||||
>>> cipher = PKCS1_OAEP.new(key)
|
||||
>>> ciphertext = cipher.encrypt(message)
|
||||
|
||||
At the receiver side, decryption can be done using the private part of
|
||||
the RSA key:
|
||||
|
||||
>>> key = RSA.importKey(open('privkey.der').read())
|
||||
>>> cipher = PKCS1_OAP.new(key)
|
||||
>>> message = cipher.decrypt(ciphertext)
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
|
||||
.. __: http://www.ietf.org/rfc/rfc3447.txt
|
||||
.. __: http://www.rsa.com/rsalabs/node.asp?id=2125.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
__revision__ = "$Id$"
|
||||
__all__ = [ 'new', 'PKCS1OAEP_Cipher' ]
|
||||
|
||||
import Crypto.Signature.PKCS1_PSS
|
||||
import Crypto.Hash.SHA
|
||||
|
||||
from Crypto.Util.py3compat import *
|
||||
import Crypto.Util.number
|
||||
from Crypto.Util.number import ceil_div
|
||||
from Crypto.Util.strxor import strxor
|
||||
|
||||
class PKCS1OAEP_Cipher:
|
||||
"""This cipher can perform PKCS#1 v1.5 OAEP encryption or decryption."""
|
||||
|
||||
def __init__(self, key, hashAlgo, mgfunc, label):
|
||||
"""Initialize this PKCS#1 OAEP cipher object.
|
||||
|
||||
:Parameters:
|
||||
key : an RSA key object
|
||||
If a private half is given, both encryption and decryption are possible.
|
||||
If a public half is given, only encryption is possible.
|
||||
hashAlgo : hash object
|
||||
The hash function to use. This can be a module under `Crypto.Hash`
|
||||
or an existing hash object created from any of such modules. If not specified,
|
||||
`Crypto.Hash.SHA` (that is, SHA-1) is used.
|
||||
mgfunc : callable
|
||||
A mask generation function that accepts two parameters: a string to
|
||||
use as seed, and the lenth of the mask to generate, in bytes.
|
||||
If not specified, the standard MGF1 is used (a safe choice).
|
||||
label : string
|
||||
A label to apply to this particular encryption. If not specified,
|
||||
an empty string is used. Specifying a label does not improve
|
||||
security.
|
||||
|
||||
:attention: Modify the mask generation function only if you know what you are doing.
|
||||
Sender and receiver must use the same one.
|
||||
"""
|
||||
self._key = key
|
||||
|
||||
if hashAlgo:
|
||||
self._hashObj = hashAlgo
|
||||
else:
|
||||
self._hashObj = Crypto.Hash.SHA
|
||||
|
||||
if mgfunc:
|
||||
self._mgf = mgfunc
|
||||
else:
|
||||
self._mgf = lambda x,y: Crypto.Signature.PKCS1_PSS.MGF1(x,y,self._hashObj)
|
||||
|
||||
self._label = label
|
||||
|
||||
def can_encrypt(self):
|
||||
"""Return True/1 if this cipher object can be used for encryption."""
|
||||
return self._key.can_encrypt()
|
||||
|
||||
def can_decrypt(self):
|
||||
"""Return True/1 if this cipher object can be used for decryption."""
|
||||
return self._key.can_decrypt()
|
||||
|
||||
def encrypt(self, message):
|
||||
"""Produce the PKCS#1 OAEP encryption of a message.
|
||||
|
||||
This function is named ``RSAES-OAEP-ENCRYPT``, and is specified in
|
||||
section 7.1.1 of RFC3447.
|
||||
|
||||
:Parameters:
|
||||
message : string
|
||||
The message to encrypt, also known as plaintext. It can be of
|
||||
variable length, but not longer than the RSA modulus (in bytes)
|
||||
minus 2, minus twice the hash output size.
|
||||
|
||||
:Return: A string, the ciphertext in which the message is encrypted.
|
||||
It is as long as the RSA modulus (in bytes).
|
||||
:Raise ValueError:
|
||||
If the RSA key length is not sufficiently long to deal with the given
|
||||
message.
|
||||
"""
|
||||
# TODO: Verify the key is RSA
|
||||
|
||||
randFunc = self._key._randfunc
|
||||
|
||||
# See 7.1.1 in RFC3447
|
||||
modBits = Crypto.Util.number.size(self._key.n)
|
||||
k = ceil_div(modBits,8) # Convert from bits to bytes
|
||||
hLen = self._hashObj.digest_size
|
||||
mLen = len(message)
|
||||
|
||||
# Step 1b
|
||||
ps_len = k-mLen-2*hLen-2
|
||||
if ps_len<0:
|
||||
raise ValueError("Plaintext is too long.")
|
||||
# Step 2a
|
||||
lHash = self._hashObj.new(self._label).digest()
|
||||
# Step 2b
|
||||
ps = bchr(0x00)*ps_len
|
||||
# Step 2c
|
||||
db = lHash + ps + bchr(0x01) + message
|
||||
# Step 2d
|
||||
ros = randFunc(hLen)
|
||||
# Step 2e
|
||||
dbMask = self._mgf(ros, k-hLen-1)
|
||||
# Step 2f
|
||||
maskedDB = strxor(db, dbMask)
|
||||
# Step 2g
|
||||
seedMask = self._mgf(maskedDB, hLen)
|
||||
# Step 2h
|
||||
maskedSeed = strxor(ros, seedMask)
|
||||
# Step 2i
|
||||
em = bchr(0x00) + maskedSeed + maskedDB
|
||||
# Step 3a (OS2IP), step 3b (RSAEP), part of step 3c (I2OSP)
|
||||
m = self._key.encrypt(em, 0)[0]
|
||||
# Complete step 3c (I2OSP)
|
||||
c = bchr(0x00)*(k-len(m)) + m
|
||||
return c
|
||||
|
||||
def decrypt(self, ct):
|
||||
"""Decrypt a PKCS#1 OAEP ciphertext.
|
||||
|
||||
This function is named ``RSAES-OAEP-DECRYPT``, and is specified in
|
||||
section 7.1.2 of RFC3447.
|
||||
|
||||
:Parameters:
|
||||
ct : string
|
||||
The ciphertext that contains the message to recover.
|
||||
|
||||
:Return: A string, the original message.
|
||||
:Raise ValueError:
|
||||
If the ciphertext length is incorrect, or if the decryption does not
|
||||
succeed.
|
||||
:Raise TypeError:
|
||||
If the RSA key has no private half.
|
||||
"""
|
||||
# TODO: Verify the key is RSA
|
||||
|
||||
# See 7.1.2 in RFC3447
|
||||
modBits = Crypto.Util.number.size(self._key.n)
|
||||
k = ceil_div(modBits,8) # Convert from bits to bytes
|
||||
hLen = self._hashObj.digest_size
|
||||
|
||||
# Step 1b and 1c
|
||||
if len(ct) != k or k<hLen+2:
|
||||
raise ValueError("Ciphertext with incorrect length.")
|
||||
# Step 2a (O2SIP), 2b (RSADP), and part of 2c (I2OSP)
|
||||
m = self._key.decrypt(ct)
|
||||
# Complete step 2c (I2OSP)
|
||||
em = bchr(0x00)*(k-len(m)) + m
|
||||
# Step 3a
|
||||
lHash = self._hashObj.new(self._label).digest()
|
||||
# Step 3b
|
||||
y = em[0]
|
||||
# y must be 0, but we MUST NOT check it here in order not to
|
||||
# allow attacks like Manger's (http://dl.acm.org/citation.cfm?id=704143)
|
||||
maskedSeed = em[1:hLen+1]
|
||||
maskedDB = em[hLen+1:]
|
||||
# Step 3c
|
||||
seedMask = self._mgf(maskedDB, hLen)
|
||||
# Step 3d
|
||||
seed = strxor(maskedSeed, seedMask)
|
||||
# Step 3e
|
||||
dbMask = self._mgf(seed, k-hLen-1)
|
||||
# Step 3f
|
||||
db = strxor(maskedDB, dbMask)
|
||||
# Step 3g
|
||||
valid = 1
|
||||
one = db[hLen:].find(bchr(0x01))
|
||||
lHash1 = db[:hLen]
|
||||
if lHash1!=lHash:
|
||||
valid = 0
|
||||
if one<0:
|
||||
valid = 0
|
||||
if bord(y)!=0:
|
||||
valid = 0
|
||||
if not valid:
|
||||
raise ValueError("Incorrect decryption.")
|
||||
# Step 4
|
||||
return db[hLen+one+1:]
|
||||
|
||||
def new(key, hashAlgo=None, mgfunc=None, label=b('')):
|
||||
"""Return a cipher object `PKCS1OAEP_Cipher` that can be used to perform PKCS#1 OAEP encryption or decryption.
|
||||
|
||||
:Parameters:
|
||||
key : RSA key object
|
||||
The key to use to encrypt or decrypt the message. This is a `Crypto.PublicKey.RSA` object.
|
||||
Decryption is only possible if *key* is a private RSA key.
|
||||
hashAlgo : hash object
|
||||
The hash function to use. This can be a module under `Crypto.Hash`
|
||||
or an existing hash object created from any of such modules. If not specified,
|
||||
`Crypto.Hash.SHA` (that is, SHA-1) is used.
|
||||
mgfunc : callable
|
||||
A mask generation function that accepts two parameters: a string to
|
||||
use as seed, and the lenth of the mask to generate, in bytes.
|
||||
If not specified, the standard MGF1 is used (a safe choice).
|
||||
label : string
|
||||
A label to apply to this particular encryption. If not specified,
|
||||
an empty string is used. Specifying a label does not improve
|
||||
security.
|
||||
|
||||
:attention: Modify the mask generation function only if you know what you are doing.
|
||||
Sender and receiver must use the same one.
|
||||
"""
|
||||
return PKCS1OAEP_Cipher(key, hashAlgo, mgfunc, label)
|
||||
|
||||
226
APPS/lib/Crypto/Cipher/PKCS1_v1_5.py
Normal file
226
APPS/lib/Crypto/Cipher/PKCS1_v1_5.py
Normal file
@@ -0,0 +1,226 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/PKCS1-v1_5.py : PKCS#1 v1.5
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
|
||||
"""RSA encryption protocol according to PKCS#1 v1.5
|
||||
|
||||
See RFC3447__ or the `original RSA Labs specification`__ .
|
||||
|
||||
This scheme is more properly called ``RSAES-PKCS1-v1_5``.
|
||||
|
||||
**If you are designing a new protocol, consider using the more robust PKCS#1 OAEP.**
|
||||
|
||||
As an example, a sender may encrypt a message in this way:
|
||||
|
||||
>>> from Crypto.Cipher import PKCS1_v1_5
|
||||
>>> from Crypto.PublicKey import RSA
|
||||
>>> from Crypto.Hash import SHA
|
||||
>>>
|
||||
>>> message = 'To be encrypted'
|
||||
>>> h = SHA.new(message)
|
||||
>>>
|
||||
>>> key = RSA.importKey(open('pubkey.der').read())
|
||||
>>> cipher = PKCS1_v1_5.new(key)
|
||||
>>> ciphertext = cipher.encrypt(message+h.digest())
|
||||
|
||||
At the receiver side, decryption can be done using the private part of
|
||||
the RSA key:
|
||||
|
||||
>>> From Crypto.Hash import SHA
|
||||
>>> from Crypto import Random
|
||||
>>>
|
||||
>>> key = RSA.importKey(open('privkey.der').read())
|
||||
>>>
|
||||
>>> dsize = SHA.digest_size
|
||||
>>> sentinel = Random.new().read(15+dsize) # Let's assume that average data length is 15
|
||||
>>>
|
||||
>>> cipher = PKCS1_v1_5.new(key)
|
||||
>>> message = cipher.decrypt(ciphertext, sentinel)
|
||||
>>>
|
||||
>>> digest = SHA.new(message[:-dsize]).digest()
|
||||
>>> if digest==message[-dsize:]: # Note how we DO NOT look for the sentinel
|
||||
>>> print "Encryption was correct."
|
||||
>>> else:
|
||||
>>> print "Encryption was not correct."
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
|
||||
.. __: http://www.ietf.org/rfc/rfc3447.txt
|
||||
.. __: http://www.rsa.com/rsalabs/node.asp?id=2125.
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
__all__ = [ 'new', 'PKCS115_Cipher' ]
|
||||
|
||||
from Crypto.Util.number import ceil_div
|
||||
from Crypto.Util.py3compat import *
|
||||
import Crypto.Util.number
|
||||
|
||||
class PKCS115_Cipher:
|
||||
"""This cipher can perform PKCS#1 v1.5 RSA encryption or decryption."""
|
||||
|
||||
def __init__(self, key):
|
||||
"""Initialize this PKCS#1 v1.5 cipher object.
|
||||
|
||||
:Parameters:
|
||||
key : an RSA key object
|
||||
If a private half is given, both encryption and decryption are possible.
|
||||
If a public half is given, only encryption is possible.
|
||||
"""
|
||||
self._key = key
|
||||
|
||||
def can_encrypt(self):
|
||||
"""Return True if this cipher object can be used for encryption."""
|
||||
return self._key.can_encrypt()
|
||||
|
||||
def can_decrypt(self):
|
||||
"""Return True if this cipher object can be used for decryption."""
|
||||
return self._key.can_decrypt()
|
||||
|
||||
def encrypt(self, message):
|
||||
"""Produce the PKCS#1 v1.5 encryption of a message.
|
||||
|
||||
This function is named ``RSAES-PKCS1-V1_5-ENCRYPT``, and is specified in
|
||||
section 7.2.1 of RFC3447.
|
||||
For a complete example see `Crypto.Cipher.PKCS1_v1_5`.
|
||||
|
||||
:Parameters:
|
||||
message : byte string
|
||||
The message to encrypt, also known as plaintext. It can be of
|
||||
variable length, but not longer than the RSA modulus (in bytes) minus 11.
|
||||
|
||||
:Return: A byte string, the ciphertext in which the message is encrypted.
|
||||
It is as long as the RSA modulus (in bytes).
|
||||
:Raise ValueError:
|
||||
If the RSA key length is not sufficiently long to deal with the given
|
||||
message.
|
||||
|
||||
"""
|
||||
# TODO: Verify the key is RSA
|
||||
|
||||
randFunc = self._key._randfunc
|
||||
|
||||
# See 7.2.1 in RFC3447
|
||||
modBits = Crypto.Util.number.size(self._key.n)
|
||||
k = ceil_div(modBits,8) # Convert from bits to bytes
|
||||
mLen = len(message)
|
||||
|
||||
# Step 1
|
||||
if mLen > k-11:
|
||||
raise ValueError("Plaintext is too long.")
|
||||
# Step 2a
|
||||
class nonZeroRandByte:
|
||||
def __init__(self, rf): self.rf=rf
|
||||
def __call__(self, c):
|
||||
while bord(c)==0x00: c=self.rf(1)[0]
|
||||
return c
|
||||
ps = tobytes(list(map(nonZeroRandByte(randFunc), randFunc(k-mLen-3))))
|
||||
# Step 2b
|
||||
em = b('\x00\x02') + ps + bchr(0x00) + message
|
||||
# Step 3a (OS2IP), step 3b (RSAEP), part of step 3c (I2OSP)
|
||||
m = self._key.encrypt(em, 0)[0]
|
||||
# Complete step 3c (I2OSP)
|
||||
c = bchr(0x00)*(k-len(m)) + m
|
||||
return c
|
||||
|
||||
def decrypt(self, ct, sentinel):
|
||||
"""Decrypt a PKCS#1 v1.5 ciphertext.
|
||||
|
||||
This function is named ``RSAES-PKCS1-V1_5-DECRYPT``, and is specified in
|
||||
section 7.2.2 of RFC3447.
|
||||
For a complete example see `Crypto.Cipher.PKCS1_v1_5`.
|
||||
|
||||
:Parameters:
|
||||
ct : byte string
|
||||
The ciphertext that contains the message to recover.
|
||||
sentinel : any type
|
||||
The object to return to indicate that an error was detected during decryption.
|
||||
|
||||
:Return: A byte string. It is either the original message or the ``sentinel`` (in case of an error).
|
||||
:Raise ValueError:
|
||||
If the ciphertext length is incorrect
|
||||
:Raise TypeError:
|
||||
If the RSA key has no private half.
|
||||
|
||||
:attention:
|
||||
You should **never** let the party who submitted the ciphertext know that
|
||||
this function returned the ``sentinel`` value.
|
||||
Armed with such knowledge (for a fair amount of carefully crafted but invalid ciphertexts),
|
||||
an attacker is able to recontruct the plaintext of any other encryption that were carried out
|
||||
with the same RSA public key (see `Bleichenbacher's`__ attack).
|
||||
|
||||
In general, it should not be possible for the other party to distinguish
|
||||
whether processing at the server side failed because the value returned
|
||||
was a ``sentinel`` as opposed to a random, invalid message.
|
||||
|
||||
In fact, the second option is not that unlikely: encryption done according to PKCS#1 v1.5
|
||||
embeds no good integrity check. There is roughly one chance
|
||||
in 2^16 for a random ciphertext to be returned as a valid message
|
||||
(although random looking).
|
||||
|
||||
It is therefore advisabled to:
|
||||
|
||||
1. Select as ``sentinel`` a value that resembles a plausable random, invalid message.
|
||||
2. Not report back an error as soon as you detect a ``sentinel`` value.
|
||||
Put differently, you should not explicitly check if the returned value is the ``sentinel`` or not.
|
||||
3. Cover all possible errors with a single, generic error indicator.
|
||||
4. Embed into the definition of ``message`` (at the protocol level) a digest (e.g. ``SHA-1``).
|
||||
It is recommended for it to be the rightmost part ``message``.
|
||||
5. Where possible, monitor the number of errors due to ciphertexts originating from the same party,
|
||||
and slow down the rate of the requests from such party (or even blacklist it altogether).
|
||||
|
||||
**If you are designing a new protocol, consider using the more robust PKCS#1 OAEP.**
|
||||
|
||||
.. __: http://www.bell-labs.com/user/bleichen/papers/pkcs.ps
|
||||
|
||||
"""
|
||||
|
||||
# TODO: Verify the key is RSA
|
||||
|
||||
# See 7.2.1 in RFC3447
|
||||
modBits = Crypto.Util.number.size(self._key.n)
|
||||
k = ceil_div(modBits,8) # Convert from bits to bytes
|
||||
|
||||
# Step 1
|
||||
if len(ct) != k:
|
||||
raise ValueError("Ciphertext with incorrect length.")
|
||||
# Step 2a (O2SIP), 2b (RSADP), and part of 2c (I2OSP)
|
||||
m = self._key.decrypt(ct)
|
||||
# Complete step 2c (I2OSP)
|
||||
em = bchr(0x00)*(k-len(m)) + m
|
||||
# Step 3
|
||||
sep = em.find(bchr(0x00),2)
|
||||
if not em.startswith(b('\x00\x02')) or sep<10:
|
||||
return sentinel
|
||||
# Step 4
|
||||
return em[sep+1:]
|
||||
|
||||
def new(key):
|
||||
"""Return a cipher object `PKCS115_Cipher` that can be used to perform PKCS#1 v1.5 encryption or decryption.
|
||||
|
||||
:Parameters:
|
||||
key : RSA key object
|
||||
The key to use to encrypt or decrypt the message. This is a `Crypto.PublicKey.RSA` object.
|
||||
Decryption is only possible if *key* is a private RSA key.
|
||||
|
||||
"""
|
||||
return PKCS115_Cipher(key)
|
||||
|
||||
86
APPS/lib/Crypto/Cipher/XOR.py
Normal file
86
APPS/lib/Crypto/Cipher/XOR.py
Normal file
@@ -0,0 +1,86 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Cipher/XOR.py : XOR
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# 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.
|
||||
# ===================================================================
|
||||
"""XOR toy cipher
|
||||
|
||||
XOR is one the simplest stream ciphers. Encryption and decryption are
|
||||
performed by XOR-ing data with a keystream made by contatenating
|
||||
the key.
|
||||
|
||||
Do not use it for real applications!
|
||||
|
||||
:undocumented: __revision__, __package__
|
||||
"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Cipher import _XOR
|
||||
|
||||
class XORCipher:
|
||||
"""XOR cipher object"""
|
||||
|
||||
def __init__(self, key, *args, **kwargs):
|
||||
"""Initialize a XOR cipher object
|
||||
|
||||
See also `new()` at the module level."""
|
||||
self._cipher = _XOR.new(key, *args, **kwargs)
|
||||
self.block_size = self._cipher.block_size
|
||||
self.key_size = self._cipher.key_size
|
||||
|
||||
def encrypt(self, plaintext):
|
||||
"""Encrypt a piece of data.
|
||||
|
||||
:Parameters:
|
||||
plaintext : byte string
|
||||
The piece of data to encrypt. It can be of any size.
|
||||
:Return: the encrypted data (byte string, as long as the
|
||||
plaintext).
|
||||
"""
|
||||
return self._cipher.encrypt(plaintext)
|
||||
|
||||
def decrypt(self, ciphertext):
|
||||
"""Decrypt a piece of data.
|
||||
|
||||
:Parameters:
|
||||
ciphertext : byte string
|
||||
The piece of data to decrypt. It can be of any size.
|
||||
:Return: the decrypted data (byte string, as long as the
|
||||
ciphertext).
|
||||
"""
|
||||
return self._cipher.decrypt(ciphertext)
|
||||
|
||||
def new(key, *args, **kwargs):
|
||||
"""Create a new XOR cipher
|
||||
|
||||
:Parameters:
|
||||
key : byte string
|
||||
The secret key to use in the symmetric cipher.
|
||||
Its length may vary from 1 to 32 bytes.
|
||||
|
||||
:Return: an `XORCipher` object
|
||||
"""
|
||||
return XORCipher(key, *args, **kwargs)
|
||||
|
||||
#: Size of a data block (in bytes)
|
||||
block_size = 1
|
||||
#: Size of a key (in bytes)
|
||||
key_size = range(1,32+1)
|
||||
|
||||
BIN
APPS/lib/Crypto/Cipher/_AES.so
Normal file
BIN
APPS/lib/Crypto/Cipher/_AES.so
Normal file
Binary file not shown.
BIN
APPS/lib/Crypto/Cipher/_ARC2.so
Normal file
BIN
APPS/lib/Crypto/Cipher/_ARC2.so
Normal file
Binary file not shown.
BIN
APPS/lib/Crypto/Cipher/_ARC4.so
Normal file
BIN
APPS/lib/Crypto/Cipher/_ARC4.so
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user