openangel commited on
Commit
a006afd
·
1 Parent(s): c4ef8fe

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .env +1 -0
  2. .gitattributes +25 -0
  3. .github/workflows/update_space.yml +28 -0
  4. .gitignore +2 -0
  5. .venv/bin/Activate.ps1 +247 -0
  6. .venv/bin/activate +69 -0
  7. .venv/bin/activate.csh +26 -0
  8. .venv/bin/activate.fish +69 -0
  9. .venv/bin/coloredlogs +8 -0
  10. .venv/bin/dotenv +8 -0
  11. .venv/bin/f2py +8 -0
  12. .venv/bin/f2py3 +8 -0
  13. .venv/bin/f2py3.11 +8 -0
  14. .venv/bin/fonttools +8 -0
  15. .venv/bin/gradio +8 -0
  16. .venv/bin/httpx +8 -0
  17. .venv/bin/huggingface-cli +8 -0
  18. .venv/bin/humanfriendly +8 -0
  19. .venv/bin/isympy +8 -0
  20. .venv/bin/jsonschema +8 -0
  21. .venv/bin/langchain-server +8 -0
  22. .venv/bin/langsmith +8 -0
  23. .venv/bin/markdown-it +8 -0
  24. .venv/bin/normalizer +8 -0
  25. .venv/bin/onnxruntime_test +8 -0
  26. .venv/bin/openai +8 -0
  27. .venv/bin/pip +8 -0
  28. .venv/bin/pip3 +8 -0
  29. .venv/bin/pip3.11 +8 -0
  30. .venv/bin/pyftmerge +8 -0
  31. .venv/bin/pyftsubset +8 -0
  32. .venv/bin/python +0 -0
  33. .venv/bin/python3 +0 -0
  34. .venv/bin/python3.11 +0 -0
  35. .venv/bin/tqdm +8 -0
  36. .venv/bin/ttx +8 -0
  37. .venv/bin/upload_theme +8 -0
  38. .venv/bin/uvicorn +8 -0
  39. .venv/bin/watchfiles +8 -0
  40. .venv/include/site/python3.11/greenlet/greenlet.h +164 -0
  41. .venv/lib/python3.11/site-packages/Crypto/Cipher/AES.py +234 -0
  42. .venv/lib/python3.11/site-packages/Crypto/Cipher/AES.pyi +154 -0
  43. .venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.py +175 -0
  44. .venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.pyi +33 -0
  45. .venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.py +136 -0
  46. .venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.pyi +14 -0
  47. .venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.py +159 -0
  48. .venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.pyi +33 -0
  49. .venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.py +159 -0
  50. .venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.pyi +33 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ OPENAI_API_KEY="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"
.gitattributes CHANGED
@@ -33,3 +33,28 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ .venv/lib/python3.11/site-packages/PIL/.dylibs/libfreetype.6.dylib filter=lfs diff=lfs merge=lfs -text
37
+ .venv/lib/python3.11/site-packages/PIL/.dylibs/libharfbuzz.0.dylib filter=lfs diff=lfs merge=lfs -text
38
+ .venv/lib/python3.11/site-packages/PIL/.dylibs/libtiff.6.dylib filter=lfs diff=lfs merge=lfs -text
39
+ .venv/lib/python3.11/site-packages/PIL/_imaging.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
40
+ .venv/lib/python3.11/site-packages/_pulsar.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
41
+ .venv/lib/python3.11/site-packages/altair/vegalite/v5/schema/__pycache__/core.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
42
+ .venv/lib/python3.11/site-packages/fitz/_fitz.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
43
+ .venv/lib/python3.11/site-packages/gradio/frpc_darwin_amd64_v0.2 filter=lfs diff=lfs merge=lfs -text
44
+ .venv/lib/python3.11/site-packages/gradio/templates/cdn/assets/index-8f25b221.js.map filter=lfs diff=lfs merge=lfs -text
45
+ .venv/lib/python3.11/site-packages/gradio/templates/frontend/assets/index-9b351176.js.map filter=lfs diff=lfs merge=lfs -text
46
+ .venv/lib/python3.11/site-packages/numpy/.dylibs/libgfortran.5.dylib filter=lfs diff=lfs merge=lfs -text
47
+ .venv/lib/python3.11/site-packages/numpy/.dylibs/libopenblas64_.0.dylib filter=lfs diff=lfs merge=lfs -text
48
+ .venv/lib/python3.11/site-packages/numpy/core/_multiarray_umath.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
49
+ .venv/lib/python3.11/site-packages/numpy/core/_simd.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
50
+ .venv/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.so filter=lfs diff=lfs merge=lfs -text
51
+ .venv/lib/python3.11/site-packages/pandas/_libs/algos.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
52
+ .venv/lib/python3.11/site-packages/pandas/_libs/groupby.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
53
+ .venv/lib/python3.11/site-packages/pandas/_libs/hashtable.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
54
+ .venv/lib/python3.11/site-packages/pandas/_libs/interval.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
55
+ .venv/lib/python3.11/site-packages/pandas/_libs/join.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
56
+ .venv/lib/python3.11/site-packages/sympy/polys/benchmarks/__pycache__/bench_solvers.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
57
+ .venv/lib/python3.11/site-packages/tiktoken/_tiktoken.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
58
+ .venv/lib/python3.11/site-packages/tokenizers/tokenizers.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
59
+ .venv/lib/python3.11/site-packages/uvloop/loop.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
60
+ .venv/lib/python3.11/site-packages/watchfiles/_rust_notify.abi3.so filter=lfs diff=lfs merge=lfs -text
.github/workflows/update_space.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Run Python script
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v2
18
+ with:
19
+ python-version: '3.9'
20
+
21
+ - name: Install Gradio
22
+ run: python -m pip install gradio
23
+
24
+ - name: Log in to Hugging Face
25
+ run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
26
+
27
+ - name: Deploy to Spaces
28
+ run: gradio deploy
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .env
2
+ .venv
.venv/bin/Activate.ps1 ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <#
2
+ .Synopsis
3
+ Activate a Python virtual environment for the current PowerShell session.
4
+
5
+ .Description
6
+ Pushes the python executable for a virtual environment to the front of the
7
+ $Env:PATH environment variable and sets the prompt to signify that you are
8
+ in a Python virtual environment. Makes use of the command line switches as
9
+ well as the `pyvenv.cfg` file values present in the virtual environment.
10
+
11
+ .Parameter VenvDir
12
+ Path to the directory that contains the virtual environment to activate. The
13
+ default value for this is the parent of the directory that the Activate.ps1
14
+ script is located within.
15
+
16
+ .Parameter Prompt
17
+ The prompt prefix to display when this virtual environment is activated. By
18
+ default, this prompt is the name of the virtual environment folder (VenvDir)
19
+ surrounded by parentheses and followed by a single space (ie. '(.venv) ').
20
+
21
+ .Example
22
+ Activate.ps1
23
+ Activates the Python virtual environment that contains the Activate.ps1 script.
24
+
25
+ .Example
26
+ Activate.ps1 -Verbose
27
+ Activates the Python virtual environment that contains the Activate.ps1 script,
28
+ and shows extra information about the activation as it executes.
29
+
30
+ .Example
31
+ Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
32
+ Activates the Python virtual environment located in the specified location.
33
+
34
+ .Example
35
+ Activate.ps1 -Prompt "MyPython"
36
+ Activates the Python virtual environment that contains the Activate.ps1 script,
37
+ and prefixes the current prompt with the specified string (surrounded in
38
+ parentheses) while the virtual environment is active.
39
+
40
+ .Notes
41
+ On Windows, it may be required to enable this Activate.ps1 script by setting the
42
+ execution policy for the user. You can do this by issuing the following PowerShell
43
+ command:
44
+
45
+ PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
46
+
47
+ For more information on Execution Policies:
48
+ https://go.microsoft.com/fwlink/?LinkID=135170
49
+
50
+ #>
51
+ Param(
52
+ [Parameter(Mandatory = $false)]
53
+ [String]
54
+ $VenvDir,
55
+ [Parameter(Mandatory = $false)]
56
+ [String]
57
+ $Prompt
58
+ )
59
+
60
+ <# Function declarations --------------------------------------------------- #>
61
+
62
+ <#
63
+ .Synopsis
64
+ Remove all shell session elements added by the Activate script, including the
65
+ addition of the virtual environment's Python executable from the beginning of
66
+ the PATH variable.
67
+
68
+ .Parameter NonDestructive
69
+ If present, do not remove this function from the global namespace for the
70
+ session.
71
+
72
+ #>
73
+ function global:deactivate ([switch]$NonDestructive) {
74
+ # Revert to original values
75
+
76
+ # The prior prompt:
77
+ if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
78
+ Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
79
+ Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
80
+ }
81
+
82
+ # The prior PYTHONHOME:
83
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
84
+ Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
85
+ Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
86
+ }
87
+
88
+ # The prior PATH:
89
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
90
+ Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
91
+ Remove-Item -Path Env:_OLD_VIRTUAL_PATH
92
+ }
93
+
94
+ # Just remove the VIRTUAL_ENV altogether:
95
+ if (Test-Path -Path Env:VIRTUAL_ENV) {
96
+ Remove-Item -Path env:VIRTUAL_ENV
97
+ }
98
+
99
+ # Just remove VIRTUAL_ENV_PROMPT altogether.
100
+ if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
101
+ Remove-Item -Path env:VIRTUAL_ENV_PROMPT
102
+ }
103
+
104
+ # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
105
+ if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
106
+ Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
107
+ }
108
+
109
+ # Leave deactivate function in the global namespace if requested:
110
+ if (-not $NonDestructive) {
111
+ Remove-Item -Path function:deactivate
112
+ }
113
+ }
114
+
115
+ <#
116
+ .Description
117
+ Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
118
+ given folder, and returns them in a map.
119
+
120
+ For each line in the pyvenv.cfg file, if that line can be parsed into exactly
121
+ two strings separated by `=` (with any amount of whitespace surrounding the =)
122
+ then it is considered a `key = value` line. The left hand string is the key,
123
+ the right hand is the value.
124
+
125
+ If the value starts with a `'` or a `"` then the first and last character is
126
+ stripped from the value before being captured.
127
+
128
+ .Parameter ConfigDir
129
+ Path to the directory that contains the `pyvenv.cfg` file.
130
+ #>
131
+ function Get-PyVenvConfig(
132
+ [String]
133
+ $ConfigDir
134
+ ) {
135
+ Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
136
+
137
+ # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
138
+ $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
139
+
140
+ # An empty map will be returned if no config file is found.
141
+ $pyvenvConfig = @{ }
142
+
143
+ if ($pyvenvConfigPath) {
144
+
145
+ Write-Verbose "File exists, parse `key = value` lines"
146
+ $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
147
+
148
+ $pyvenvConfigContent | ForEach-Object {
149
+ $keyval = $PSItem -split "\s*=\s*", 2
150
+ if ($keyval[0] -and $keyval[1]) {
151
+ $val = $keyval[1]
152
+
153
+ # Remove extraneous quotations around a string value.
154
+ if ("'""".Contains($val.Substring(0, 1))) {
155
+ $val = $val.Substring(1, $val.Length - 2)
156
+ }
157
+
158
+ $pyvenvConfig[$keyval[0]] = $val
159
+ Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
160
+ }
161
+ }
162
+ }
163
+ return $pyvenvConfig
164
+ }
165
+
166
+
167
+ <# Begin Activate script --------------------------------------------------- #>
168
+
169
+ # Determine the containing directory of this script
170
+ $VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
171
+ $VenvExecDir = Get-Item -Path $VenvExecPath
172
+
173
+ Write-Verbose "Activation script is located in path: '$VenvExecPath'"
174
+ Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
175
+ Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
176
+
177
+ # Set values required in priority: CmdLine, ConfigFile, Default
178
+ # First, get the location of the virtual environment, it might not be
179
+ # VenvExecDir if specified on the command line.
180
+ if ($VenvDir) {
181
+ Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
182
+ }
183
+ else {
184
+ Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
185
+ $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
186
+ Write-Verbose "VenvDir=$VenvDir"
187
+ }
188
+
189
+ # Next, read the `pyvenv.cfg` file to determine any required value such
190
+ # as `prompt`.
191
+ $pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
192
+
193
+ # Next, set the prompt from the command line, or the config file, or
194
+ # just use the name of the virtual environment folder.
195
+ if ($Prompt) {
196
+ Write-Verbose "Prompt specified as argument, using '$Prompt'"
197
+ }
198
+ else {
199
+ Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
200
+ if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
201
+ Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
202
+ $Prompt = $pyvenvCfg['prompt'];
203
+ }
204
+ else {
205
+ Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
206
+ Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
207
+ $Prompt = Split-Path -Path $venvDir -Leaf
208
+ }
209
+ }
210
+
211
+ Write-Verbose "Prompt = '$Prompt'"
212
+ Write-Verbose "VenvDir='$VenvDir'"
213
+
214
+ # Deactivate any currently active virtual environment, but leave the
215
+ # deactivate function in place.
216
+ deactivate -nondestructive
217
+
218
+ # Now set the environment variable VIRTUAL_ENV, used by many tools to determine
219
+ # that there is an activated venv.
220
+ $env:VIRTUAL_ENV = $VenvDir
221
+
222
+ if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
223
+
224
+ Write-Verbose "Setting prompt to '$Prompt'"
225
+
226
+ # Set the prompt to include the env name
227
+ # Make sure _OLD_VIRTUAL_PROMPT is global
228
+ function global:_OLD_VIRTUAL_PROMPT { "" }
229
+ Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
230
+ New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
231
+
232
+ function global:prompt {
233
+ Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
234
+ _OLD_VIRTUAL_PROMPT
235
+ }
236
+ $env:VIRTUAL_ENV_PROMPT = $Prompt
237
+ }
238
+
239
+ # Clear PYTHONHOME
240
+ if (Test-Path -Path Env:PYTHONHOME) {
241
+ Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
242
+ Remove-Item -Path Env:PYTHONHOME
243
+ }
244
+
245
+ # Add the venv to the PATH
246
+ Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
247
+ $Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
.venv/bin/activate ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate" *from bash*
2
+ # you cannot run it directly
3
+
4
+ deactivate () {
5
+ # reset old environment variables
6
+ if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7
+ PATH="${_OLD_VIRTUAL_PATH:-}"
8
+ export PATH
9
+ unset _OLD_VIRTUAL_PATH
10
+ fi
11
+ if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12
+ PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13
+ export PYTHONHOME
14
+ unset _OLD_VIRTUAL_PYTHONHOME
15
+ fi
16
+
17
+ # This should detect bash and zsh, which have a hash command that must
18
+ # be called to get it to forget past commands. Without forgetting
19
+ # past commands the $PATH changes we made may not be respected
20
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21
+ hash -r 2> /dev/null
22
+ fi
23
+
24
+ if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
25
+ PS1="${_OLD_VIRTUAL_PS1:-}"
26
+ export PS1
27
+ unset _OLD_VIRTUAL_PS1
28
+ fi
29
+
30
+ unset VIRTUAL_ENV
31
+ unset VIRTUAL_ENV_PROMPT
32
+ if [ ! "${1:-}" = "nondestructive" ] ; then
33
+ # Self destruct!
34
+ unset -f deactivate
35
+ fi
36
+ }
37
+
38
+ # unset irrelevant variables
39
+ deactivate nondestructive
40
+
41
+ VIRTUAL_ENV="/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv"
42
+ export VIRTUAL_ENV
43
+
44
+ _OLD_VIRTUAL_PATH="$PATH"
45
+ PATH="$VIRTUAL_ENV/bin:$PATH"
46
+ export PATH
47
+
48
+ # unset PYTHONHOME if set
49
+ # this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
50
+ # could use `if (set -u; : $PYTHONHOME) ;` in bash
51
+ if [ -n "${PYTHONHOME:-}" ] ; then
52
+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
53
+ unset PYTHONHOME
54
+ fi
55
+
56
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
57
+ _OLD_VIRTUAL_PS1="${PS1:-}"
58
+ PS1="(.venv) ${PS1:-}"
59
+ export PS1
60
+ VIRTUAL_ENV_PROMPT="(.venv) "
61
+ export VIRTUAL_ENV_PROMPT
62
+ fi
63
+
64
+ # This should detect bash and zsh, which have a hash command that must
65
+ # be called to get it to forget past commands. Without forgetting
66
+ # past commands the $PATH changes we made may not be respected
67
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
68
+ hash -r 2> /dev/null
69
+ fi
.venv/bin/activate.csh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate.csh" *from csh*.
2
+ # You cannot run it directly.
3
+ # Created by Davide Di Blasi <[email protected]>.
4
+ # Ported to Python 3.3 venv by Andrew Svetlov <[email protected]>
5
+
6
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
7
+
8
+ # Unset irrelevant variables.
9
+ deactivate nondestructive
10
+
11
+ setenv VIRTUAL_ENV "/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv"
12
+
13
+ set _OLD_VIRTUAL_PATH="$PATH"
14
+ setenv PATH "$VIRTUAL_ENV/bin:$PATH"
15
+
16
+
17
+ set _OLD_VIRTUAL_PROMPT="$prompt"
18
+
19
+ if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
20
+ set prompt = "(.venv) $prompt"
21
+ setenv VIRTUAL_ENV_PROMPT "(.venv) "
22
+ endif
23
+
24
+ alias pydoc python -m pydoc
25
+
26
+ rehash
.venv/bin/activate.fish ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source <venv>/bin/activate.fish" *from fish*
2
+ # (https://fishshell.com/); you cannot run it directly.
3
+
4
+ function deactivate -d "Exit virtual environment and return to normal shell environment"
5
+ # reset old environment variables
6
+ if test -n "$_OLD_VIRTUAL_PATH"
7
+ set -gx PATH $_OLD_VIRTUAL_PATH
8
+ set -e _OLD_VIRTUAL_PATH
9
+ end
10
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11
+ set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12
+ set -e _OLD_VIRTUAL_PYTHONHOME
13
+ end
14
+
15
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16
+ set -e _OLD_FISH_PROMPT_OVERRIDE
17
+ # prevents error when using nested fish instances (Issue #93858)
18
+ if functions -q _old_fish_prompt
19
+ functions -e fish_prompt
20
+ functions -c _old_fish_prompt fish_prompt
21
+ functions -e _old_fish_prompt
22
+ end
23
+ end
24
+
25
+ set -e VIRTUAL_ENV
26
+ set -e VIRTUAL_ENV_PROMPT
27
+ if test "$argv[1]" != "nondestructive"
28
+ # Self-destruct!
29
+ functions -e deactivate
30
+ end
31
+ end
32
+
33
+ # Unset irrelevant variables.
34
+ deactivate nondestructive
35
+
36
+ set -gx VIRTUAL_ENV "/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv"
37
+
38
+ set -gx _OLD_VIRTUAL_PATH $PATH
39
+ set -gx PATH "$VIRTUAL_ENV/bin" $PATH
40
+
41
+ # Unset PYTHONHOME if set.
42
+ if set -q PYTHONHOME
43
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
44
+ set -e PYTHONHOME
45
+ end
46
+
47
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
48
+ # fish uses a function instead of an env var to generate the prompt.
49
+
50
+ # Save the current fish_prompt function as the function _old_fish_prompt.
51
+ functions -c fish_prompt _old_fish_prompt
52
+
53
+ # With the original prompt function renamed, we can override with our own.
54
+ function fish_prompt
55
+ # Save the return status of the last command.
56
+ set -l old_status $status
57
+
58
+ # Output the venv prompt; color taken from the blue of the Python logo.
59
+ printf "%s%s%s" (set_color 4B8BBE) "(.venv) " (set_color normal)
60
+
61
+ # Restore the return status of the previous command.
62
+ echo "exit $old_status" | .
63
+ # Output the original/"old" prompt.
64
+ _old_fish_prompt
65
+ end
66
+
67
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
68
+ set -gx VIRTUAL_ENV_PROMPT "(.venv) "
69
+ end
.venv/bin/coloredlogs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from coloredlogs.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/dotenv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from dotenv.__main__ import cli
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli())
.venv/bin/f2py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from numpy.f2py.f2py2e import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/f2py3 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from numpy.f2py.f2py2e import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/f2py3.11 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from numpy.f2py.f2py2e import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/fonttools ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.__main__ import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/gradio ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from gradio.cli import cli
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli())
.venv/bin/httpx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from httpx import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/huggingface-cli ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from huggingface_hub.commands.huggingface_cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/humanfriendly ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from humanfriendly.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/isympy ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from isympy import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/jsonschema ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from jsonschema.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/langchain-server ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from langchain.server import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/langsmith ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from langsmith.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/markdown-it ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from markdown_it.cli.parse import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/normalizer ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from charset_normalizer.cli.normalizer import cli_detect
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli_detect())
.venv/bin/onnxruntime_test ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from onnxruntime.tools.onnxruntime_test import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/openai ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from openai._openai_scripts import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/pip ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/pip3 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/pip3.11 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/pyftmerge ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.merge import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/pyftsubset ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.subset import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/python ADDED
Binary file (49.8 kB). View file
 
.venv/bin/python3 ADDED
Binary file (49.8 kB). View file
 
.venv/bin/python3.11 ADDED
Binary file (49.8 kB). View file
 
.venv/bin/tqdm ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from tqdm.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/ttx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.ttx import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/upload_theme ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from gradio.themes.upload_theme import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/uvicorn ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from uvicorn.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
.venv/bin/watchfiles ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/ispirett/PythonProjects/AI/pdfq-a-ai/.venv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from watchfiles.cli import cli
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli())
.venv/include/site/python3.11/greenlet/greenlet.h ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* -*- indent-tabs-mode: nil; tab-width: 4; -*- */
2
+
3
+ /* Greenlet object interface */
4
+
5
+ #ifndef Py_GREENLETOBJECT_H
6
+ #define Py_GREENLETOBJECT_H
7
+
8
+
9
+ #include <Python.h>
10
+
11
+ #ifdef __cplusplus
12
+ extern "C" {
13
+ #endif
14
+
15
+ /* This is deprecated and undocumented. It does not change. */
16
+ #define GREENLET_VERSION "1.0.0"
17
+
18
+ #ifndef GREENLET_MODULE
19
+ #define implementation_ptr_t void*
20
+ #endif
21
+
22
+ typedef struct _greenlet {
23
+ PyObject_HEAD
24
+ PyObject* weakreflist;
25
+ PyObject* dict;
26
+ implementation_ptr_t pimpl;
27
+ } PyGreenlet;
28
+
29
+ #define PyGreenlet_Check(op) (op && PyObject_TypeCheck(op, &PyGreenlet_Type))
30
+
31
+
32
+ /* C API functions */
33
+
34
+ /* Total number of symbols that are exported */
35
+ #define PyGreenlet_API_pointers 12
36
+
37
+ #define PyGreenlet_Type_NUM 0
38
+ #define PyExc_GreenletError_NUM 1
39
+ #define PyExc_GreenletExit_NUM 2
40
+
41
+ #define PyGreenlet_New_NUM 3
42
+ #define PyGreenlet_GetCurrent_NUM 4
43
+ #define PyGreenlet_Throw_NUM 5
44
+ #define PyGreenlet_Switch_NUM 6
45
+ #define PyGreenlet_SetParent_NUM 7
46
+
47
+ #define PyGreenlet_MAIN_NUM 8
48
+ #define PyGreenlet_STARTED_NUM 9
49
+ #define PyGreenlet_ACTIVE_NUM 10
50
+ #define PyGreenlet_GET_PARENT_NUM 11
51
+
52
+ #ifndef GREENLET_MODULE
53
+ /* This section is used by modules that uses the greenlet C API */
54
+ static void** _PyGreenlet_API = NULL;
55
+
56
+ # define PyGreenlet_Type \
57
+ (*(PyTypeObject*)_PyGreenlet_API[PyGreenlet_Type_NUM])
58
+
59
+ # define PyExc_GreenletError \
60
+ ((PyObject*)_PyGreenlet_API[PyExc_GreenletError_NUM])
61
+
62
+ # define PyExc_GreenletExit \
63
+ ((PyObject*)_PyGreenlet_API[PyExc_GreenletExit_NUM])
64
+
65
+ /*
66
+ * PyGreenlet_New(PyObject *args)
67
+ *
68
+ * greenlet.greenlet(run, parent=None)
69
+ */
70
+ # define PyGreenlet_New \
71
+ (*(PyGreenlet * (*)(PyObject * run, PyGreenlet * parent)) \
72
+ _PyGreenlet_API[PyGreenlet_New_NUM])
73
+
74
+ /*
75
+ * PyGreenlet_GetCurrent(void)
76
+ *
77
+ * greenlet.getcurrent()
78
+ */
79
+ # define PyGreenlet_GetCurrent \
80
+ (*(PyGreenlet * (*)(void)) _PyGreenlet_API[PyGreenlet_GetCurrent_NUM])
81
+
82
+ /*
83
+ * PyGreenlet_Throw(
84
+ * PyGreenlet *greenlet,
85
+ * PyObject *typ,
86
+ * PyObject *val,
87
+ * PyObject *tb)
88
+ *
89
+ * g.throw(...)
90
+ */
91
+ # define PyGreenlet_Throw \
92
+ (*(PyObject * (*)(PyGreenlet * self, \
93
+ PyObject * typ, \
94
+ PyObject * val, \
95
+ PyObject * tb)) \
96
+ _PyGreenlet_API[PyGreenlet_Throw_NUM])
97
+
98
+ /*
99
+ * PyGreenlet_Switch(PyGreenlet *greenlet, PyObject *args)
100
+ *
101
+ * g.switch(*args, **kwargs)
102
+ */
103
+ # define PyGreenlet_Switch \
104
+ (*(PyObject * \
105
+ (*)(PyGreenlet * greenlet, PyObject * args, PyObject * kwargs)) \
106
+ _PyGreenlet_API[PyGreenlet_Switch_NUM])
107
+
108
+ /*
109
+ * PyGreenlet_SetParent(PyObject *greenlet, PyObject *new_parent)
110
+ *
111
+ * g.parent = new_parent
112
+ */
113
+ # define PyGreenlet_SetParent \
114
+ (*(int (*)(PyGreenlet * greenlet, PyGreenlet * nparent)) \
115
+ _PyGreenlet_API[PyGreenlet_SetParent_NUM])
116
+
117
+ /*
118
+ * PyGreenlet_GetParent(PyObject* greenlet)
119
+ *
120
+ * return greenlet.parent;
121
+ *
122
+ * This could return NULL even if there is no exception active.
123
+ * If it does not return NULL, you are responsible for decrementing the
124
+ * reference count.
125
+ */
126
+ # define PyGreenlet_GetParent \
127
+ (*(PyGreenlet* (*)(PyGreenlet*)) \
128
+ _PyGreenlet_API[PyGreenlet_GET_PARENT_NUM])
129
+
130
+ /*
131
+ * deprecated, undocumented alias.
132
+ */
133
+ # define PyGreenlet_GET_PARENT PyGreenlet_GetParent
134
+
135
+ # define PyGreenlet_MAIN \
136
+ (*(int (*)(PyGreenlet*)) \
137
+ _PyGreenlet_API[PyGreenlet_MAIN_NUM])
138
+
139
+ # define PyGreenlet_STARTED \
140
+ (*(int (*)(PyGreenlet*)) \
141
+ _PyGreenlet_API[PyGreenlet_STARTED_NUM])
142
+
143
+ # define PyGreenlet_ACTIVE \
144
+ (*(int (*)(PyGreenlet*)) \
145
+ _PyGreenlet_API[PyGreenlet_ACTIVE_NUM])
146
+
147
+
148
+
149
+
150
+ /* Macro that imports greenlet and initializes C API */
151
+ /* NOTE: This has actually moved to ``greenlet._greenlet._C_API``, but we
152
+ keep the older definition to be sure older code that might have a copy of
153
+ the header still works. */
154
+ # define PyGreenlet_Import() \
155
+ { \
156
+ _PyGreenlet_API = (void**)PyCapsule_Import("greenlet._C_API", 0); \
157
+ }
158
+
159
+ #endif /* GREENLET_MODULE */
160
+
161
+ #ifdef __cplusplus
162
+ }
163
+ #endif
164
+ #endif /* !Py_GREENLETOBJECT_H */
.venv/lib/python3.11/site-packages/Crypto/Cipher/AES.py ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Cipher/AES.py : AES
4
+ #
5
+ # ===================================================================
6
+ # The contents of this file are dedicated to the public domain. To
7
+ # the extent that dedication to the public domain is not available,
8
+ # everyone is granted a worldwide, perpetual, royalty-free,
9
+ # non-exclusive license to exercise all rights associated with the
10
+ # contents of this file for any purpose whatsoever.
11
+ # No rights are reserved.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ # ===================================================================
22
+
23
+ import sys
24
+
25
+ from Crypto.Cipher import _create_cipher
26
+ from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
27
+ VoidPointer, SmartPointer,
28
+ c_size_t, c_uint8_ptr)
29
+
30
+ from Crypto.Util import _cpu_features
31
+ from Crypto.Random import get_random_bytes
32
+
33
+ MODE_ECB = 1 #: Electronic Code Book (:ref:`ecb_mode`)
34
+ MODE_CBC = 2 #: Cipher-Block Chaining (:ref:`cbc_mode`)
35
+ MODE_CFB = 3 #: Cipher Feedback (:ref:`cfb_mode`)
36
+ MODE_OFB = 5 #: Output Feedback (:ref:`ofb_mode`)
37
+ MODE_CTR = 6 #: Counter mode (:ref:`ctr_mode`)
38
+ MODE_OPENPGP = 7 #: OpenPGP mode (:ref:`openpgp_mode`)
39
+ MODE_CCM = 8 #: Counter with CBC-MAC (:ref:`ccm_mode`)
40
+ MODE_EAX = 9 #: :ref:`eax_mode`
41
+ MODE_SIV = 10 #: Synthetic Initialization Vector (:ref:`siv_mode`)
42
+ MODE_GCM = 11 #: Galois Counter Mode (:ref:`gcm_mode`)
43
+ MODE_OCB = 12 #: Offset Code Book (:ref:`ocb_mode`)
44
+
45
+
46
+ _cproto = """
47
+ int AES_start_operation(const uint8_t key[],
48
+ size_t key_len,
49
+ void **pResult);
50
+ int AES_encrypt(const void *state,
51
+ const uint8_t *in,
52
+ uint8_t *out,
53
+ size_t data_len);
54
+ int AES_decrypt(const void *state,
55
+ const uint8_t *in,
56
+ uint8_t *out,
57
+ size_t data_len);
58
+ int AES_stop_operation(void *state);
59
+ """
60
+
61
+
62
+ # Load portable AES
63
+ _raw_aes_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aes",
64
+ _cproto)
65
+
66
+ # Try to load AES with AES NI instructions
67
+ try:
68
+ _raw_aesni_lib = None
69
+ if _cpu_features.have_aes_ni():
70
+ _raw_aesni_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aesni",
71
+ _cproto.replace("AES",
72
+ "AESNI"))
73
+ # _raw_aesni may not have been compiled in
74
+ except OSError:
75
+ pass
76
+
77
+
78
+ def _create_base_cipher(dict_parameters):
79
+ """This method instantiates and returns a handle to a low-level
80
+ base cipher. It will absorb named parameters in the process."""
81
+
82
+ use_aesni = dict_parameters.pop("use_aesni", True)
83
+
84
+ try:
85
+ key = dict_parameters.pop("key")
86
+ except KeyError:
87
+ raise TypeError("Missing 'key' parameter")
88
+
89
+ if len(key) not in key_size:
90
+ raise ValueError("Incorrect AES key length (%d bytes)" % len(key))
91
+
92
+ if use_aesni and _raw_aesni_lib:
93
+ start_operation = _raw_aesni_lib.AESNI_start_operation
94
+ stop_operation = _raw_aesni_lib.AESNI_stop_operation
95
+ else:
96
+ start_operation = _raw_aes_lib.AES_start_operation
97
+ stop_operation = _raw_aes_lib.AES_stop_operation
98
+
99
+ cipher = VoidPointer()
100
+ result = start_operation(c_uint8_ptr(key),
101
+ c_size_t(len(key)),
102
+ cipher.address_of())
103
+ if result:
104
+ raise ValueError("Error %X while instantiating the AES cipher"
105
+ % result)
106
+ return SmartPointer(cipher.get(), stop_operation)
107
+
108
+
109
+ def _derive_Poly1305_key_pair(key, nonce):
110
+ """Derive a tuple (r, s, nonce) for a Poly1305 MAC.
111
+
112
+ If nonce is ``None``, a new 16-byte nonce is generated.
113
+ """
114
+
115
+ if len(key) != 32:
116
+ raise ValueError("Poly1305 with AES requires a 32-byte key")
117
+
118
+ if nonce is None:
119
+ nonce = get_random_bytes(16)
120
+ elif len(nonce) != 16:
121
+ raise ValueError("Poly1305 with AES requires a 16-byte nonce")
122
+
123
+ s = new(key[:16], MODE_ECB).encrypt(nonce)
124
+ return key[16:], s, nonce
125
+
126
+
127
+ def new(key, mode, *args, **kwargs):
128
+ """Create a new AES cipher.
129
+
130
+ Args:
131
+ key(bytes/bytearray/memoryview):
132
+ The secret key to use in the symmetric cipher.
133
+
134
+ It must be 16 (*AES-128)*, 24 (*AES-192*) or 32 (*AES-256*) bytes long.
135
+
136
+ For ``MODE_SIV`` only, it doubles to 32, 48, or 64 bytes.
137
+ mode (a ``MODE_*`` constant):
138
+ The chaining mode to use for encryption or decryption.
139
+ If in doubt, use ``MODE_EAX``.
140
+
141
+ Keyword Args:
142
+ iv (bytes/bytearray/memoryview):
143
+ (Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
144
+ and ``MODE_OPENPGP`` modes).
145
+
146
+ The initialization vector to use for encryption or decryption.
147
+
148
+ For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 16 bytes long.
149
+
150
+ For ``MODE_OPENPGP`` mode only,
151
+ it must be 16 bytes long for encryption
152
+ and 18 bytes for decryption (in the latter case, it is
153
+ actually the *encrypted* IV which was prefixed to the ciphertext).
154
+
155
+ If not provided, a random byte string is generated (you must then
156
+ read its value with the :attr:`iv` attribute).
157
+
158
+ nonce (bytes/bytearray/memoryview):
159
+ (Only applicable for ``MODE_CCM``, ``MODE_EAX``, ``MODE_GCM``,
160
+ ``MODE_SIV``, ``MODE_OCB``, and ``MODE_CTR``).
161
+
162
+ A value that must never be reused for any other encryption done
163
+ with this key (except possibly for ``MODE_SIV``, see below).
164
+
165
+ For ``MODE_EAX``, ``MODE_GCM`` and ``MODE_SIV`` there are no
166
+ restrictions on its length (recommended: **16** bytes).
167
+
168
+ For ``MODE_CCM``, its length must be in the range **[7..13]**.
169
+ Bear in mind that with CCM there is a trade-off between nonce
170
+ length and maximum message size. Recommendation: **11** bytes.
171
+
172
+ For ``MODE_OCB``, its length must be in the range **[1..15]**
173
+ (recommended: **15**).
174
+
175
+ For ``MODE_CTR``, its length must be in the range **[0..15]**
176
+ (recommended: **8**).
177
+
178
+ For ``MODE_SIV``, the nonce is optional, if it is not specified,
179
+ then no nonce is being used, which renders the encryption
180
+ deterministic.
181
+
182
+ If not provided, for modes other than ``MODE_SIV``, a random
183
+ byte string of the recommended length is used (you must then
184
+ read its value with the :attr:`nonce` attribute).
185
+
186
+ segment_size (integer):
187
+ (Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
188
+ are segmented in. It must be a multiple of 8.
189
+ If not specified, it will be assumed to be 8.
190
+
191
+ mac_len (integer):
192
+ (Only ``MODE_EAX``, ``MODE_GCM``, ``MODE_OCB``, ``MODE_CCM``)
193
+ Length of the authentication tag, in bytes.
194
+
195
+ It must be even and in the range **[4..16]**.
196
+ The recommended value (and the default, if not specified) is **16**.
197
+
198
+ msg_len (integer):
199
+ (Only ``MODE_CCM``). Length of the message to (de)cipher.
200
+ If not specified, ``encrypt`` must be called with the entire message.
201
+ Similarly, ``decrypt`` can only be called once.
202
+
203
+ assoc_len (integer):
204
+ (Only ``MODE_CCM``). Length of the associated data.
205
+ If not specified, all associated data is buffered internally,
206
+ which may represent a problem for very large messages.
207
+
208
+ initial_value (integer or bytes/bytearray/memoryview):
209
+ (Only ``MODE_CTR``).
210
+ The initial value for the counter. If not present, the cipher will
211
+ start counting from 0. The value is incremented by one for each block.
212
+ The counter number is encoded in big endian mode.
213
+
214
+ counter (object):
215
+ (Only ``MODE_CTR``).
216
+ Instance of ``Crypto.Util.Counter``, which allows full customization
217
+ of the counter block. This parameter is incompatible to both ``nonce``
218
+ and ``initial_value``.
219
+
220
+ use_aesni: (boolean):
221
+ Use Intel AES-NI hardware extensions (default: use if available).
222
+
223
+ Returns:
224
+ an AES object, of the applicable mode.
225
+ """
226
+
227
+ kwargs["add_aes_modes"] = True
228
+ return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
229
+
230
+
231
+ # Size of a data block (in bytes)
232
+ block_size = 16
233
+ # Size of a key (in bytes)
234
+ key_size = (16, 24, 32)
.venv/lib/python3.11/site-packages/Crypto/Cipher/AES.pyi ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import ByteString, Dict, Optional, Tuple, Union, overload
2
+ from typing_extensions import Literal
3
+
4
+ from Crypto.Cipher._mode_ecb import EcbMode
5
+ from Crypto.Cipher._mode_cbc import CbcMode
6
+ from Crypto.Cipher._mode_cfb import CfbMode
7
+ from Crypto.Cipher._mode_ofb import OfbMode
8
+ from Crypto.Cipher._mode_ctr import CtrMode
9
+ from Crypto.Cipher._mode_openpgp import OpenPgpMode
10
+ from Crypto.Cipher._mode_ccm import CcmMode
11
+ from Crypto.Cipher._mode_eax import EaxMode
12
+ from Crypto.Cipher._mode_gcm import GcmMode
13
+ from Crypto.Cipher._mode_siv import SivMode
14
+ from Crypto.Cipher._mode_ocb import OcbMode
15
+
16
+ MODE_ECB: Literal[1]
17
+ MODE_CBC: Literal[2]
18
+ MODE_CFB: Literal[3]
19
+ MODE_OFB: Literal[5]
20
+ MODE_CTR: Literal[6]
21
+ MODE_OPENPGP: Literal[7]
22
+ MODE_CCM: Literal[8]
23
+ MODE_EAX: Literal[9]
24
+ MODE_SIV: Literal[10]
25
+ MODE_GCM: Literal[11]
26
+ MODE_OCB: Literal[12]
27
+
28
+ # MODE_ECB
29
+ @overload
30
+ def new(key: ByteString,
31
+ mode: Literal[1],
32
+ use_aesni : bool = ...) -> \
33
+ EcbMode: ...
34
+
35
+ # MODE_CBC
36
+ @overload
37
+ def new(key: ByteString,
38
+ mode: Literal[2],
39
+ iv : Optional[ByteString] = ...,
40
+ use_aesni : bool = ...) -> \
41
+ CbcMode: ...
42
+
43
+ @overload
44
+ def new(key: ByteString,
45
+ mode: Literal[2],
46
+ IV : Optional[ByteString] = ...,
47
+ use_aesni : bool = ...) -> \
48
+ CbcMode: ...
49
+
50
+ # MODE_CFB
51
+ @overload
52
+ def new(key: ByteString,
53
+ mode: Literal[3],
54
+ iv : Optional[ByteString] = ...,
55
+ segment_size : int = ...,
56
+ use_aesni : bool = ...) -> \
57
+ CfbMode: ...
58
+
59
+ @overload
60
+ def new(key: ByteString,
61
+ mode: Literal[3],
62
+ IV : Optional[ByteString] = ...,
63
+ segment_size : int = ...,
64
+ use_aesni : bool = ...) -> \
65
+ CfbMode: ...
66
+
67
+ # MODE_OFB
68
+ @overload
69
+ def new(key: ByteString,
70
+ mode: Literal[5],
71
+ iv : Optional[ByteString] = ...,
72
+ use_aesni : bool = ...) -> \
73
+ OfbMode: ...
74
+
75
+ @overload
76
+ def new(key: ByteString,
77
+ mode: Literal[5],
78
+ IV : Optional[ByteString] = ...,
79
+ use_aesni : bool = ...) -> \
80
+ OfbMode: ...
81
+
82
+ # MODE_CTR
83
+ @overload
84
+ def new(key: ByteString,
85
+ mode: Literal[6],
86
+ nonce : Optional[ByteString] = ...,
87
+ initial_value : Union[int, ByteString] = ...,
88
+ counter : Dict = ...,
89
+ use_aesni : bool = ...) -> \
90
+ CtrMode: ...
91
+
92
+ # MODE_OPENPGP
93
+ @overload
94
+ def new(key: ByteString,
95
+ mode: Literal[7],
96
+ iv : Optional[ByteString] = ...,
97
+ use_aesni : bool = ...) -> \
98
+ OpenPgpMode: ...
99
+
100
+ @overload
101
+ def new(key: ByteString,
102
+ mode: Literal[7],
103
+ IV : Optional[ByteString] = ...,
104
+ use_aesni : bool = ...) -> \
105
+ OpenPgpMode: ...
106
+
107
+ # MODE_CCM
108
+ @overload
109
+ def new(key: ByteString,
110
+ mode: Literal[8],
111
+ nonce : Optional[ByteString] = ...,
112
+ mac_len : int = ...,
113
+ assoc_len : int = ...,
114
+ use_aesni : bool = ...) -> \
115
+ CcmMode: ...
116
+
117
+ # MODE_EAX
118
+ @overload
119
+ def new(key: ByteString,
120
+ mode: Literal[9],
121
+ nonce : Optional[ByteString] = ...,
122
+ mac_len : int = ...,
123
+ use_aesni : bool = ...) -> \
124
+ EaxMode: ...
125
+
126
+ # MODE_GCM
127
+ @overload
128
+ def new(key: ByteString,
129
+ mode: Literal[10],
130
+ nonce : Optional[ByteString] = ...,
131
+ use_aesni : bool = ...) -> \
132
+ SivMode: ...
133
+
134
+ # MODE_SIV
135
+ @overload
136
+ def new(key: ByteString,
137
+ mode: Literal[11],
138
+ nonce : Optional[ByteString] = ...,
139
+ mac_len : int = ...,
140
+ use_aesni : bool = ...) -> \
141
+ GcmMode: ...
142
+
143
+ # MODE_OCB
144
+ @overload
145
+ def new(key: ByteString,
146
+ mode: Literal[12],
147
+ nonce : Optional[ByteString] = ...,
148
+ mac_len : int = ...,
149
+ use_aesni : bool = ...) -> \
150
+ OcbMode: ...
151
+
152
+
153
+ block_size: int
154
+ key_size: Tuple[int, int, int]
.venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Cipher/ARC2.py : ARC2.py
4
+ #
5
+ # ===================================================================
6
+ # The contents of this file are dedicated to the public domain. To
7
+ # the extent that dedication to the public domain is not available,
8
+ # everyone is granted a worldwide, perpetual, royalty-free,
9
+ # non-exclusive license to exercise all rights associated with the
10
+ # contents of this file for any purpose whatsoever.
11
+ # No rights are reserved.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ # ===================================================================
22
+ """
23
+ Module's constants for the modes of operation supported with ARC2:
24
+
25
+ :var MODE_ECB: :ref:`Electronic Code Book (ECB) <ecb_mode>`
26
+ :var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) <cbc_mode>`
27
+ :var MODE_CFB: :ref:`Cipher FeedBack (CFB) <cfb_mode>`
28
+ :var MODE_OFB: :ref:`Output FeedBack (OFB) <ofb_mode>`
29
+ :var MODE_CTR: :ref:`CounTer Mode (CTR) <ctr_mode>`
30
+ :var MODE_OPENPGP: :ref:`OpenPGP Mode <openpgp_mode>`
31
+ :var MODE_EAX: :ref:`EAX Mode <eax_mode>`
32
+ """
33
+
34
+ import sys
35
+
36
+ from Crypto.Cipher import _create_cipher
37
+ from Crypto.Util.py3compat import byte_string
38
+ from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
39
+ VoidPointer, SmartPointer,
40
+ c_size_t, c_uint8_ptr)
41
+
42
+ _raw_arc2_lib = load_pycryptodome_raw_lib(
43
+ "Crypto.Cipher._raw_arc2",
44
+ """
45
+ int ARC2_start_operation(const uint8_t key[],
46
+ size_t key_len,
47
+ size_t effective_key_len,
48
+ void **pResult);
49
+ int ARC2_encrypt(const void *state,
50
+ const uint8_t *in,
51
+ uint8_t *out,
52
+ size_t data_len);
53
+ int ARC2_decrypt(const void *state,
54
+ const uint8_t *in,
55
+ uint8_t *out,
56
+ size_t data_len);
57
+ int ARC2_stop_operation(void *state);
58
+ """
59
+ )
60
+
61
+
62
+ def _create_base_cipher(dict_parameters):
63
+ """This method instantiates and returns a handle to a low-level
64
+ base cipher. It will absorb named parameters in the process."""
65
+
66
+ try:
67
+ key = dict_parameters.pop("key")
68
+ except KeyError:
69
+ raise TypeError("Missing 'key' parameter")
70
+
71
+ effective_keylen = dict_parameters.pop("effective_keylen", 1024)
72
+
73
+ if len(key) not in key_size:
74
+ raise ValueError("Incorrect ARC2 key length (%d bytes)" % len(key))
75
+
76
+ if not (40 <= effective_keylen <= 1024):
77
+ raise ValueError("'effective_key_len' must be at least 40 and no larger than 1024 "
78
+ "(not %d)" % effective_keylen)
79
+
80
+ start_operation = _raw_arc2_lib.ARC2_start_operation
81
+ stop_operation = _raw_arc2_lib.ARC2_stop_operation
82
+
83
+ cipher = VoidPointer()
84
+ result = start_operation(c_uint8_ptr(key),
85
+ c_size_t(len(key)),
86
+ c_size_t(effective_keylen),
87
+ cipher.address_of())
88
+ if result:
89
+ raise ValueError("Error %X while instantiating the ARC2 cipher"
90
+ % result)
91
+
92
+ return SmartPointer(cipher.get(), stop_operation)
93
+
94
+
95
+ def new(key, mode, *args, **kwargs):
96
+ """Create a new RC2 cipher.
97
+
98
+ :param key:
99
+ The secret key to use in the symmetric cipher.
100
+ Its length can vary from 5 to 128 bytes; the actual search space
101
+ (and the cipher strength) can be reduced with the ``effective_keylen`` parameter.
102
+ :type key: bytes, bytearray, memoryview
103
+
104
+ :param mode:
105
+ The chaining mode to use for encryption or decryption.
106
+ :type mode: One of the supported ``MODE_*`` constants
107
+
108
+ :Keyword Arguments:
109
+ * **iv** (*bytes*, *bytearray*, *memoryview*) --
110
+ (Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
111
+ and ``MODE_OPENPGP`` modes).
112
+
113
+ The initialization vector to use for encryption or decryption.
114
+
115
+ For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 8 bytes long.
116
+
117
+ For ``MODE_OPENPGP`` mode only,
118
+ it must be 8 bytes long for encryption
119
+ and 10 bytes for decryption (in the latter case, it is
120
+ actually the *encrypted* IV which was prefixed to the ciphertext).
121
+
122
+ If not provided, a random byte string is generated (you must then
123
+ read its value with the :attr:`iv` attribute).
124
+
125
+ * **nonce** (*bytes*, *bytearray*, *memoryview*) --
126
+ (Only applicable for ``MODE_EAX`` and ``MODE_CTR``).
127
+
128
+ A value that must never be reused for any other encryption done
129
+ with this key.
130
+
131
+ For ``MODE_EAX`` there are no
132
+ restrictions on its length (recommended: **16** bytes).
133
+
134
+ For ``MODE_CTR``, its length must be in the range **[0..7]**.
135
+
136
+ If not provided for ``MODE_EAX``, a random byte string is generated (you
137
+ can read it back via the ``nonce`` attribute).
138
+
139
+ * **effective_keylen** (*integer*) --
140
+ Optional. Maximum strength in bits of the actual key used by the ARC2 algorithm.
141
+ If the supplied ``key`` parameter is longer (in bits) of the value specified
142
+ here, it will be weakened to match it.
143
+ If not specified, no limitation is applied.
144
+
145
+ * **segment_size** (*integer*) --
146
+ (Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
147
+ are segmented in. It must be a multiple of 8.
148
+ If not specified, it will be assumed to be 8.
149
+
150
+ * **mac_len** : (*integer*) --
151
+ (Only ``MODE_EAX``)
152
+ Length of the authentication tag, in bytes.
153
+ It must be no longer than 8 (default).
154
+
155
+ * **initial_value** : (*integer*) --
156
+ (Only ``MODE_CTR``). The initial value for the counter within
157
+ the counter block. By default it is **0**.
158
+
159
+ :Return: an ARC2 object, of the applicable mode.
160
+ """
161
+
162
+ return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
163
+
164
+ MODE_ECB = 1
165
+ MODE_CBC = 2
166
+ MODE_CFB = 3
167
+ MODE_OFB = 5
168
+ MODE_CTR = 6
169
+ MODE_OPENPGP = 7
170
+ MODE_EAX = 9
171
+
172
+ # Size of a data block (in bytes)
173
+ block_size = 8
174
+ # Size of a key (in bytes)
175
+ key_size = range(5, 128 + 1)
.venv/lib/python3.11/site-packages/Crypto/Cipher/ARC2.pyi ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union, Dict, Iterable, Optional, ByteString
2
+
3
+ from Crypto.Cipher._mode_ecb import EcbMode
4
+ from Crypto.Cipher._mode_cbc import CbcMode
5
+ from Crypto.Cipher._mode_cfb import CfbMode
6
+ from Crypto.Cipher._mode_ofb import OfbMode
7
+ from Crypto.Cipher._mode_ctr import CtrMode
8
+ from Crypto.Cipher._mode_openpgp import OpenPgpMode
9
+ from Crypto.Cipher._mode_eax import EaxMode
10
+
11
+ ARC2Mode = int
12
+
13
+ MODE_ECB: ARC2Mode
14
+ MODE_CBC: ARC2Mode
15
+ MODE_CFB: ARC2Mode
16
+ MODE_OFB: ARC2Mode
17
+ MODE_CTR: ARC2Mode
18
+ MODE_OPENPGP: ARC2Mode
19
+ MODE_EAX: ARC2Mode
20
+
21
+ def new(key: ByteString,
22
+ mode: ARC2Mode,
23
+ iv : Optional[ByteString] = ...,
24
+ IV : Optional[ByteString] = ...,
25
+ nonce : Optional[ByteString] = ...,
26
+ segment_size : int = ...,
27
+ mac_len : int = ...,
28
+ initial_value : Union[int, ByteString] = ...,
29
+ counter : Dict = ...) -> \
30
+ Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...
31
+
32
+ block_size: int
33
+ key_size: Iterable[int]
.venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Cipher/ARC4.py : ARC4
4
+ #
5
+ # ===================================================================
6
+ # The contents of this file are dedicated to the public domain. To
7
+ # the extent that dedication to the public domain is not available,
8
+ # everyone is granted a worldwide, perpetual, royalty-free,
9
+ # non-exclusive license to exercise all rights associated with the
10
+ # contents of this file for any purpose whatsoever.
11
+ # No rights are reserved.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ # ===================================================================
22
+
23
+ from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer,
24
+ create_string_buffer, get_raw_buffer,
25
+ SmartPointer, c_size_t, c_uint8_ptr)
26
+
27
+
28
+ _raw_arc4_lib = load_pycryptodome_raw_lib("Crypto.Cipher._ARC4", """
29
+ int ARC4_stream_encrypt(void *rc4State, const uint8_t in[],
30
+ uint8_t out[], size_t len);
31
+ int ARC4_stream_init(uint8_t *key, size_t keylen,
32
+ void **pRc4State);
33
+ int ARC4_stream_destroy(void *rc4State);
34
+ """)
35
+
36
+
37
+ class ARC4Cipher:
38
+ """ARC4 cipher object. Do not create it directly. Use
39
+ :func:`Crypto.Cipher.ARC4.new` instead.
40
+ """
41
+
42
+ def __init__(self, key, *args, **kwargs):
43
+ """Initialize an ARC4 cipher object
44
+
45
+ See also `new()` at the module level."""
46
+
47
+ if len(args) > 0:
48
+ ndrop = args[0]
49
+ args = args[1:]
50
+ else:
51
+ ndrop = kwargs.pop('drop', 0)
52
+
53
+ if len(key) not in key_size:
54
+ raise ValueError("Incorrect ARC4 key length (%d bytes)" %
55
+ len(key))
56
+
57
+ self._state = VoidPointer()
58
+ result = _raw_arc4_lib.ARC4_stream_init(c_uint8_ptr(key),
59
+ c_size_t(len(key)),
60
+ self._state.address_of())
61
+ if result != 0:
62
+ raise ValueError("Error %d while creating the ARC4 cipher"
63
+ % result)
64
+ self._state = SmartPointer(self._state.get(),
65
+ _raw_arc4_lib.ARC4_stream_destroy)
66
+
67
+ if ndrop > 0:
68
+ # This is OK even if the cipher is used for decryption,
69
+ # since encrypt and decrypt are actually the same thing
70
+ # with ARC4.
71
+ self.encrypt(b'\x00' * ndrop)
72
+
73
+ self.block_size = 1
74
+ self.key_size = len(key)
75
+
76
+ def encrypt(self, plaintext):
77
+ """Encrypt a piece of data.
78
+
79
+ :param plaintext: The data to encrypt, of any size.
80
+ :type plaintext: bytes, bytearray, memoryview
81
+ :returns: the encrypted byte string, of equal length as the
82
+ plaintext.
83
+ """
84
+
85
+ ciphertext = create_string_buffer(len(plaintext))
86
+ result = _raw_arc4_lib.ARC4_stream_encrypt(self._state.get(),
87
+ c_uint8_ptr(plaintext),
88
+ ciphertext,
89
+ c_size_t(len(plaintext)))
90
+ if result:
91
+ raise ValueError("Error %d while encrypting with RC4" % result)
92
+ return get_raw_buffer(ciphertext)
93
+
94
+ def decrypt(self, ciphertext):
95
+ """Decrypt a piece of data.
96
+
97
+ :param ciphertext: The data to decrypt, of any size.
98
+ :type ciphertext: bytes, bytearray, memoryview
99
+ :returns: the decrypted byte string, of equal length as the
100
+ ciphertext.
101
+ """
102
+
103
+ try:
104
+ return self.encrypt(ciphertext)
105
+ except ValueError as e:
106
+ raise ValueError(str(e).replace("enc", "dec"))
107
+
108
+
109
+ def new(key, *args, **kwargs):
110
+ """Create a new ARC4 cipher.
111
+
112
+ :param key:
113
+ The secret key to use in the symmetric cipher.
114
+ Its length must be in the range ``[1..256]``.
115
+ The recommended length is 16 bytes.
116
+ :type key: bytes, bytearray, memoryview
117
+
118
+ :Keyword Arguments:
119
+ * *drop* (``integer``) --
120
+ The amount of bytes to discard from the initial part of the keystream.
121
+ In fact, such part has been found to be distinguishable from random
122
+ data (while it shouldn't) and also correlated to key.
123
+
124
+ The recommended value is 3072_ bytes. The default value is 0.
125
+
126
+ :Return: an `ARC4Cipher` object
127
+
128
+ .. _3072: http://eprint.iacr.org/2002/067.pdf
129
+ """
130
+ return ARC4Cipher(key, *args, **kwargs)
131
+
132
+
133
+ # Size of a data block (in bytes)
134
+ block_size = 1
135
+ # Size of a key (in bytes)
136
+ key_size = range(1, 256+1)
.venv/lib/python3.11/site-packages/Crypto/Cipher/ARC4.pyi ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, Union, Iterable, ByteString
2
+
3
+ class ARC4Cipher:
4
+ block_size: int
5
+ key_size: int
6
+
7
+ def __init__(self, key: ByteString, *args: Any, **kwargs: Any) -> None: ...
8
+ def encrypt(self, plaintext: ByteString) -> bytes: ...
9
+ def decrypt(self, ciphertext: ByteString) -> bytes: ...
10
+
11
+ def new(key: ByteString, drop : int = ...) -> ARC4Cipher: ...
12
+
13
+ block_size: int
14
+ key_size: Iterable[int]
.venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Cipher/Blowfish.py : Blowfish
4
+ #
5
+ # ===================================================================
6
+ # The contents of this file are dedicated to the public domain. To
7
+ # the extent that dedication to the public domain is not available,
8
+ # everyone is granted a worldwide, perpetual, royalty-free,
9
+ # non-exclusive license to exercise all rights associated with the
10
+ # contents of this file for any purpose whatsoever.
11
+ # No rights are reserved.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ # ===================================================================
22
+ """
23
+ Module's constants for the modes of operation supported with Blowfish:
24
+
25
+ :var MODE_ECB: :ref:`Electronic Code Book (ECB) <ecb_mode>`
26
+ :var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) <cbc_mode>`
27
+ :var MODE_CFB: :ref:`Cipher FeedBack (CFB) <cfb_mode>`
28
+ :var MODE_OFB: :ref:`Output FeedBack (OFB) <ofb_mode>`
29
+ :var MODE_CTR: :ref:`CounTer Mode (CTR) <ctr_mode>`
30
+ :var MODE_OPENPGP: :ref:`OpenPGP Mode <openpgp_mode>`
31
+ :var MODE_EAX: :ref:`EAX Mode <eax_mode>`
32
+ """
33
+
34
+ import sys
35
+
36
+ from Crypto.Cipher import _create_cipher
37
+ from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
38
+ VoidPointer, SmartPointer, c_size_t,
39
+ c_uint8_ptr)
40
+
41
+ _raw_blowfish_lib = load_pycryptodome_raw_lib(
42
+ "Crypto.Cipher._raw_blowfish",
43
+ """
44
+ int Blowfish_start_operation(const uint8_t key[],
45
+ size_t key_len,
46
+ void **pResult);
47
+ int Blowfish_encrypt(const void *state,
48
+ const uint8_t *in,
49
+ uint8_t *out,
50
+ size_t data_len);
51
+ int Blowfish_decrypt(const void *state,
52
+ const uint8_t *in,
53
+ uint8_t *out,
54
+ size_t data_len);
55
+ int Blowfish_stop_operation(void *state);
56
+ """
57
+ )
58
+
59
+
60
+ def _create_base_cipher(dict_parameters):
61
+ """This method instantiates and returns a smart pointer to
62
+ a low-level base cipher. It will absorb named parameters in
63
+ the process."""
64
+
65
+ try:
66
+ key = dict_parameters.pop("key")
67
+ except KeyError:
68
+ raise TypeError("Missing 'key' parameter")
69
+
70
+ if len(key) not in key_size:
71
+ raise ValueError("Incorrect Blowfish key length (%d bytes)" % len(key))
72
+
73
+ start_operation = _raw_blowfish_lib.Blowfish_start_operation
74
+ stop_operation = _raw_blowfish_lib.Blowfish_stop_operation
75
+
76
+ void_p = VoidPointer()
77
+ result = start_operation(c_uint8_ptr(key),
78
+ c_size_t(len(key)),
79
+ void_p.address_of())
80
+ if result:
81
+ raise ValueError("Error %X while instantiating the Blowfish cipher"
82
+ % result)
83
+ return SmartPointer(void_p.get(), stop_operation)
84
+
85
+
86
+ def new(key, mode, *args, **kwargs):
87
+ """Create a new Blowfish cipher
88
+
89
+ :param key:
90
+ The secret key to use in the symmetric cipher.
91
+ Its length can vary from 5 to 56 bytes.
92
+ :type key: bytes, bytearray, memoryview
93
+
94
+ :param mode:
95
+ The chaining mode to use for encryption or decryption.
96
+ :type mode: One of the supported ``MODE_*`` constants
97
+
98
+ :Keyword Arguments:
99
+ * **iv** (*bytes*, *bytearray*, *memoryview*) --
100
+ (Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
101
+ and ``MODE_OPENPGP`` modes).
102
+
103
+ The initialization vector to use for encryption or decryption.
104
+
105
+ For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 8 bytes long.
106
+
107
+ For ``MODE_OPENPGP`` mode only,
108
+ it must be 8 bytes long for encryption
109
+ and 10 bytes for decryption (in the latter case, it is
110
+ actually the *encrypted* IV which was prefixed to the ciphertext).
111
+
112
+ If not provided, a random byte string is generated (you must then
113
+ read its value with the :attr:`iv` attribute).
114
+
115
+ * **nonce** (*bytes*, *bytearray*, *memoryview*) --
116
+ (Only applicable for ``MODE_EAX`` and ``MODE_CTR``).
117
+
118
+ A value that must never be reused for any other encryption done
119
+ with this key.
120
+
121
+ For ``MODE_EAX`` there are no
122
+ restrictions on its length (recommended: **16** bytes).
123
+
124
+ For ``MODE_CTR``, its length must be in the range **[0..7]**.
125
+
126
+ If not provided for ``MODE_EAX``, a random byte string is generated (you
127
+ can read it back via the ``nonce`` attribute).
128
+
129
+ * **segment_size** (*integer*) --
130
+ (Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
131
+ are segmented in. It must be a multiple of 8.
132
+ If not specified, it will be assumed to be 8.
133
+
134
+ * **mac_len** : (*integer*) --
135
+ (Only ``MODE_EAX``)
136
+ Length of the authentication tag, in bytes.
137
+ It must be no longer than 8 (default).
138
+
139
+ * **initial_value** : (*integer*) --
140
+ (Only ``MODE_CTR``). The initial value for the counter within
141
+ the counter block. By default it is **0**.
142
+
143
+ :Return: a Blowfish object, of the applicable mode.
144
+ """
145
+
146
+ return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
147
+
148
+ MODE_ECB = 1
149
+ MODE_CBC = 2
150
+ MODE_CFB = 3
151
+ MODE_OFB = 5
152
+ MODE_CTR = 6
153
+ MODE_OPENPGP = 7
154
+ MODE_EAX = 9
155
+
156
+ # Size of a data block (in bytes)
157
+ block_size = 8
158
+ # Size of a key (in bytes)
159
+ key_size = range(4, 56 + 1)
.venv/lib/python3.11/site-packages/Crypto/Cipher/Blowfish.pyi ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union, Dict, Iterable, ByteString, Optional
2
+
3
+ from Crypto.Cipher._mode_ecb import EcbMode
4
+ from Crypto.Cipher._mode_cbc import CbcMode
5
+ from Crypto.Cipher._mode_cfb import CfbMode
6
+ from Crypto.Cipher._mode_ofb import OfbMode
7
+ from Crypto.Cipher._mode_ctr import CtrMode
8
+ from Crypto.Cipher._mode_openpgp import OpenPgpMode
9
+ from Crypto.Cipher._mode_eax import EaxMode
10
+
11
+ BlowfishMode = int
12
+
13
+ MODE_ECB: BlowfishMode
14
+ MODE_CBC: BlowfishMode
15
+ MODE_CFB: BlowfishMode
16
+ MODE_OFB: BlowfishMode
17
+ MODE_CTR: BlowfishMode
18
+ MODE_OPENPGP: BlowfishMode
19
+ MODE_EAX: BlowfishMode
20
+
21
+ def new(key: ByteString,
22
+ mode: BlowfishMode,
23
+ iv : Optional[ByteString] = ...,
24
+ IV : Optional[ByteString] = ...,
25
+ nonce : Optional[ByteString] = ...,
26
+ segment_size : int = ...,
27
+ mac_len : int = ...,
28
+ initial_value : Union[int, ByteString] = ...,
29
+ counter : Dict = ...) -> \
30
+ Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...
31
+
32
+ block_size: int
33
+ key_size: Iterable[int]
.venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Cipher/CAST.py : CAST
4
+ #
5
+ # ===================================================================
6
+ # The contents of this file are dedicated to the public domain. To
7
+ # the extent that dedication to the public domain is not available,
8
+ # everyone is granted a worldwide, perpetual, royalty-free,
9
+ # non-exclusive license to exercise all rights associated with the
10
+ # contents of this file for any purpose whatsoever.
11
+ # No rights are reserved.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ # ===================================================================
22
+ """
23
+ Module's constants for the modes of operation supported with CAST:
24
+
25
+ :var MODE_ECB: :ref:`Electronic Code Book (ECB) <ecb_mode>`
26
+ :var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) <cbc_mode>`
27
+ :var MODE_CFB: :ref:`Cipher FeedBack (CFB) <cfb_mode>`
28
+ :var MODE_OFB: :ref:`Output FeedBack (OFB) <ofb_mode>`
29
+ :var MODE_CTR: :ref:`CounTer Mode (CTR) <ctr_mode>`
30
+ :var MODE_OPENPGP: :ref:`OpenPGP Mode <openpgp_mode>`
31
+ :var MODE_EAX: :ref:`EAX Mode <eax_mode>`
32
+ """
33
+
34
+ import sys
35
+
36
+ from Crypto.Cipher import _create_cipher
37
+ from Crypto.Util.py3compat import byte_string
38
+ from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
39
+ VoidPointer, SmartPointer,
40
+ c_size_t, c_uint8_ptr)
41
+
42
+ _raw_cast_lib = load_pycryptodome_raw_lib(
43
+ "Crypto.Cipher._raw_cast",
44
+ """
45
+ int CAST_start_operation(const uint8_t key[],
46
+ size_t key_len,
47
+ void **pResult);
48
+ int CAST_encrypt(const void *state,
49
+ const uint8_t *in,
50
+ uint8_t *out,
51
+ size_t data_len);
52
+ int CAST_decrypt(const void *state,
53
+ const uint8_t *in,
54
+ uint8_t *out,
55
+ size_t data_len);
56
+ int CAST_stop_operation(void *state);
57
+ """)
58
+
59
+
60
+ def _create_base_cipher(dict_parameters):
61
+ """This method instantiates and returns a handle to a low-level
62
+ base cipher. It will absorb named parameters in the process."""
63
+
64
+ try:
65
+ key = dict_parameters.pop("key")
66
+ except KeyError:
67
+ raise TypeError("Missing 'key' parameter")
68
+
69
+ if len(key) not in key_size:
70
+ raise ValueError("Incorrect CAST key length (%d bytes)" % len(key))
71
+
72
+ start_operation = _raw_cast_lib.CAST_start_operation
73
+ stop_operation = _raw_cast_lib.CAST_stop_operation
74
+
75
+ cipher = VoidPointer()
76
+ result = start_operation(c_uint8_ptr(key),
77
+ c_size_t(len(key)),
78
+ cipher.address_of())
79
+ if result:
80
+ raise ValueError("Error %X while instantiating the CAST cipher"
81
+ % result)
82
+
83
+ return SmartPointer(cipher.get(), stop_operation)
84
+
85
+
86
+ def new(key, mode, *args, **kwargs):
87
+ """Create a new CAST cipher
88
+
89
+ :param key:
90
+ The secret key to use in the symmetric cipher.
91
+ Its length can vary from 5 to 16 bytes.
92
+ :type key: bytes, bytearray, memoryview
93
+
94
+ :param mode:
95
+ The chaining mode to use for encryption or decryption.
96
+ :type mode: One of the supported ``MODE_*`` constants
97
+
98
+ :Keyword Arguments:
99
+ * **iv** (*bytes*, *bytearray*, *memoryview*) --
100
+ (Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
101
+ and ``MODE_OPENPGP`` modes).
102
+
103
+ The initialization vector to use for encryption or decryption.
104
+
105
+ For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 8 bytes long.
106
+
107
+ For ``MODE_OPENPGP`` mode only,
108
+ it must be 8 bytes long for encryption
109
+ and 10 bytes for decryption (in the latter case, it is
110
+ actually the *encrypted* IV which was prefixed to the ciphertext).
111
+
112
+ If not provided, a random byte string is generated (you must then
113
+ read its value with the :attr:`iv` attribute).
114
+
115
+ * **nonce** (*bytes*, *bytearray*, *memoryview*) --
116
+ (Only applicable for ``MODE_EAX`` and ``MODE_CTR``).
117
+
118
+ A value that must never be reused for any other encryption done
119
+ with this key.
120
+
121
+ For ``MODE_EAX`` there are no
122
+ restrictions on its length (recommended: **16** bytes).
123
+
124
+ For ``MODE_CTR``, its length must be in the range **[0..7]**.
125
+
126
+ If not provided for ``MODE_EAX``, a random byte string is generated (you
127
+ can read it back via the ``nonce`` attribute).
128
+
129
+ * **segment_size** (*integer*) --
130
+ (Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
131
+ are segmented in. It must be a multiple of 8.
132
+ If not specified, it will be assumed to be 8.
133
+
134
+ * **mac_len** : (*integer*) --
135
+ (Only ``MODE_EAX``)
136
+ Length of the authentication tag, in bytes.
137
+ It must be no longer than 8 (default).
138
+
139
+ * **initial_value** : (*integer*) --
140
+ (Only ``MODE_CTR``). The initial value for the counter within
141
+ the counter block. By default it is **0**.
142
+
143
+ :Return: a CAST object, of the applicable mode.
144
+ """
145
+
146
+ return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
147
+
148
+ MODE_ECB = 1
149
+ MODE_CBC = 2
150
+ MODE_CFB = 3
151
+ MODE_OFB = 5
152
+ MODE_CTR = 6
153
+ MODE_OPENPGP = 7
154
+ MODE_EAX = 9
155
+
156
+ # Size of a data block (in bytes)
157
+ block_size = 8
158
+ # Size of a key (in bytes)
159
+ key_size = range(5, 16 + 1)
.venv/lib/python3.11/site-packages/Crypto/Cipher/CAST.pyi ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union, Dict, Iterable, Optional, ByteString
2
+
3
+ from Crypto.Cipher._mode_ecb import EcbMode
4
+ from Crypto.Cipher._mode_cbc import CbcMode
5
+ from Crypto.Cipher._mode_cfb import CfbMode
6
+ from Crypto.Cipher._mode_ofb import OfbMode
7
+ from Crypto.Cipher._mode_ctr import CtrMode
8
+ from Crypto.Cipher._mode_openpgp import OpenPgpMode
9
+ from Crypto.Cipher._mode_eax import EaxMode
10
+
11
+ CASTMode = int
12
+
13
+ MODE_ECB: CASTMode
14
+ MODE_CBC: CASTMode
15
+ MODE_CFB: CASTMode
16
+ MODE_OFB: CASTMode
17
+ MODE_CTR: CASTMode
18
+ MODE_OPENPGP: CASTMode
19
+ MODE_EAX: CASTMode
20
+
21
+ def new(key: ByteString,
22
+ mode: CASTMode,
23
+ iv : Optional[ByteString] = ...,
24
+ IV : Optional[ByteString] = ...,
25
+ nonce : Optional[ByteString] = ...,
26
+ segment_size : int = ...,
27
+ mac_len : int = ...,
28
+ initial_value : Union[int, ByteString] = ...,
29
+ counter : Dict = ...) -> \
30
+ Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...
31
+
32
+ block_size: int
33
+ key_size : Iterable[int]