Migrating repo
383
.gitignore
vendored
Normal file
@ -0,0 +1,383 @@
|
|||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/macos,xcode,swift,python,node
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,xcode,swift,python,node
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
Icon\r
|
||||||
|
"Icon\r"
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
### Node ###
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
.env*.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
pytestdebug.log
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
doc/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
pythonenv*
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# profiling data
|
||||||
|
.prof
|
||||||
|
|
||||||
|
### Swift ###
|
||||||
|
# Xcode
|
||||||
|
#
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
## User settings
|
||||||
|
xcuserdata/
|
||||||
|
|
||||||
|
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||||
|
*.xcscmblueprint
|
||||||
|
*.xccheckout
|
||||||
|
|
||||||
|
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||||
|
DerivedData/
|
||||||
|
*.moved-aside
|
||||||
|
*.pbxuser
|
||||||
|
!default.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
!default.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
!default.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
!default.perspectivev3
|
||||||
|
|
||||||
|
## Obj-C/Swift specific
|
||||||
|
*.hmap
|
||||||
|
|
||||||
|
## App packaging
|
||||||
|
*.ipa
|
||||||
|
*.dSYM.zip
|
||||||
|
*.dSYM
|
||||||
|
|
||||||
|
## Playgrounds
|
||||||
|
timeline.xctimeline
|
||||||
|
playground.xcworkspace
|
||||||
|
|
||||||
|
# Swift Package Manager
|
||||||
|
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||||
|
# Packages/
|
||||||
|
# Package.pins
|
||||||
|
# Package.resolved
|
||||||
|
# *.xcodeproj
|
||||||
|
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
|
||||||
|
# hence it is not needed unless you have added a package configuration file to your project
|
||||||
|
# .swiftpm
|
||||||
|
|
||||||
|
.build/
|
||||||
|
|
||||||
|
# CocoaPods
|
||||||
|
# We recommend against adding the Pods directory to your .gitignore. However
|
||||||
|
# you should judge for yourself, the pros and cons are mentioned at:
|
||||||
|
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||||
|
# Pods/
|
||||||
|
# Add this line if you want to avoid checking in source code from the Xcode workspace
|
||||||
|
# *.xcworkspace
|
||||||
|
|
||||||
|
# Carthage
|
||||||
|
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||||
|
# Carthage/Checkouts
|
||||||
|
|
||||||
|
Carthage/Build/
|
||||||
|
|
||||||
|
# Accio dependency management
|
||||||
|
Dependencies/
|
||||||
|
.accio/
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
# It is recommended to not store the screenshots in the git repo.
|
||||||
|
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
|
||||||
|
# For more information about the recommended setup visit:
|
||||||
|
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||||
|
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/Preview.html
|
||||||
|
fastlane/screenshots/**/*.png
|
||||||
|
fastlane/test_output
|
||||||
|
|
||||||
|
# Code Injection
|
||||||
|
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||||
|
# https://github.com/johnno1962/injectionforxcode
|
||||||
|
|
||||||
|
iOSInjectionProject/
|
||||||
|
|
||||||
|
### Xcode ###
|
||||||
|
# Xcode
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Gcc Patch
|
||||||
|
/*.gcno
|
||||||
|
|
||||||
|
### Xcode Patch ###
|
||||||
|
*.xcodeproj/*
|
||||||
|
!*.xcodeproj/project.pbxproj
|
||||||
|
!*.xcodeproj/xcshareddata/
|
||||||
|
!*.xcworkspace/contents.xcworkspacedata
|
||||||
|
**/xcshareddata/WorkspaceSettings.xcsettings
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/macos,xcode,swift,python,node
|
||||||
2
IoT-Node/.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
381
IoT-Node/.gitignore
vendored
Normal file
@ -0,0 +1,381 @@
|
|||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/macos,xcode,swift,python,node
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,xcode,swift,python,node
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
### Node ###
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
.env*.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
pytestdebug.log
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
doc/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
pythonenv*
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# profiling data
|
||||||
|
.prof
|
||||||
|
|
||||||
|
### Swift ###
|
||||||
|
# Xcode
|
||||||
|
#
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
## User settings
|
||||||
|
xcuserdata/
|
||||||
|
|
||||||
|
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||||
|
*.xcscmblueprint
|
||||||
|
*.xccheckout
|
||||||
|
|
||||||
|
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||||
|
DerivedData/
|
||||||
|
*.moved-aside
|
||||||
|
*.pbxuser
|
||||||
|
!default.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
!default.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
!default.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
!default.perspectivev3
|
||||||
|
|
||||||
|
## Obj-C/Swift specific
|
||||||
|
*.hmap
|
||||||
|
|
||||||
|
## App packaging
|
||||||
|
*.ipa
|
||||||
|
*.dSYM.zip
|
||||||
|
*.dSYM
|
||||||
|
|
||||||
|
## Playgrounds
|
||||||
|
timeline.xctimeline
|
||||||
|
playground.xcworkspace
|
||||||
|
|
||||||
|
# Swift Package Manager
|
||||||
|
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||||
|
# Packages/
|
||||||
|
# Package.pins
|
||||||
|
# Package.resolved
|
||||||
|
# *.xcodeproj
|
||||||
|
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
|
||||||
|
# hence it is not needed unless you have added a package configuration file to your project
|
||||||
|
# .swiftpm
|
||||||
|
|
||||||
|
.build/
|
||||||
|
|
||||||
|
# CocoaPods
|
||||||
|
# We recommend against adding the Pods directory to your .gitignore. However
|
||||||
|
# you should judge for yourself, the pros and cons are mentioned at:
|
||||||
|
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||||
|
# Pods/
|
||||||
|
# Add this line if you want to avoid checking in source code from the Xcode workspace
|
||||||
|
# *.xcworkspace
|
||||||
|
|
||||||
|
# Carthage
|
||||||
|
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||||
|
# Carthage/Checkouts
|
||||||
|
|
||||||
|
Carthage/Build/
|
||||||
|
|
||||||
|
# Accio dependency management
|
||||||
|
Dependencies/
|
||||||
|
.accio/
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
# It is recommended to not store the screenshots in the git repo.
|
||||||
|
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
|
||||||
|
# For more information about the recommended setup visit:
|
||||||
|
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||||
|
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/Preview.html
|
||||||
|
fastlane/screenshots/**/*.png
|
||||||
|
fastlane/test_output
|
||||||
|
|
||||||
|
# Code Injection
|
||||||
|
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||||
|
# https://github.com/johnno1962/injectionforxcode
|
||||||
|
|
||||||
|
iOSInjectionProject/
|
||||||
|
|
||||||
|
### Xcode ###
|
||||||
|
# Xcode
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Gcc Patch
|
||||||
|
/*.gcno
|
||||||
|
|
||||||
|
### Xcode Patch ###
|
||||||
|
*.xcodeproj/*
|
||||||
|
!*.xcodeproj/project.pbxproj
|
||||||
|
!*.xcodeproj/xcshareddata/
|
||||||
|
!*.xcworkspace/contents.xcworkspacedata
|
||||||
|
**/xcshareddata/WorkspaceSettings.xcsettings
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/macos,xcode,swift,python,node
|
||||||
8
IoT-Node/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
FROM node:latest
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
COPY . .
|
||||||
|
RUN npm install
|
||||||
|
EXPOSE 5050
|
||||||
|
RUN apt update
|
||||||
|
RUN apt install htop
|
||||||
|
CMD [ "node", "server.js" ]
|
||||||
0
IoT-Node/Icon
Normal file
3
IoT-Node/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# IoT
|
||||||
|
|
||||||
|
IoT test
|
||||||
5067
IoT-Node/package-lock.json
generated
Normal file
27
IoT-Node/package.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "iot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "IoT test",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "node server.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://git@git.maxhunt.design:9999/MAX/IoT.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.19.2",
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
|
"ejs": "^3.1.2",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"firebase-admin": "^8.12.0",
|
||||||
|
"firebase-tools": "^8.2.0",
|
||||||
|
"morgan": "^1.10.0",
|
||||||
|
"request": "^2.88.2",
|
||||||
|
"requests": "^0.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"type": "service_account",
|
||||||
|
"project_id": "de-iot",
|
||||||
|
"private_key_id": "be74faaf8c2e319563982dc215922650d148122d",
|
||||||
|
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDBdtbNZjofVaW4\nPnmrqerHcz7dJAQGS27KujHzFkSoSSwTvJo8ka/hcRCOUWVVRZxmg2gny3l4OsPl\nBSfa8shbNRpRZb6MgrZlYfRtmqmmtMb7Ng2QVMZwlOwlShRxDZgz/WwPgN8Q01TK\nt5gmPhfBVqe/hAT8L92gUzIHpbAEaRgILpdWh09fFbhx6IFZs7MOJ0TcXEzeN1dU\nZw3IkFwu6Ki3NJsexTD0ivfBySGAigWRyEjMyG7QuRb6Pbjz2fM5upoLKMimUK4s\nPeySplMraB8i9ulkjdjlZwIRhJD69vZq58AS1HAhOtyYp7kccQvjaipYhhQxztAT\ndS+enZM9AgMBAAECggEAOcHOWAzcbk1mB67TKS41suzTiDa/4tczUN+smNt9jNYn\njA7i5xFBdmcIX8yqGX6KNkql1jeXYI7+u8lBwEp6CUy9ui5LaGx/op3PWMdzPZs7\nynS1MPE2OxcitvE6UBQUa/UNBUXekondBxYvnL8t3WEO/Iyf5mAt5LbhuUm8Vlw6\n0pRfP+dG7Ci0mZq7iQSCq9402lGMBYBfSeI6NiyM7KeJKYWeNf1QjLqib9hT3eej\nzm/tegDUgksJBIe3BYQwnaLBkuP2AEoXFycgY5FktTMoQJy+7LLZiJOHGl/dpKJe\nvntQCSFE+3SHQixvdW6I9b3+4/14BGZylIDGNFlAWwKBgQDiwq0JkPjudY44dwS9\ngIJPVps1GtWtxp4YGQTxFHLcnB/xGIz0qPSNyLqyfqIIWDG2sGslsUp3P8VyH03m\ndNE/qclZToFVldKWFnFUwwtOTNu9pjtP+jnbnXG+NNtpWjBqXMyRjb2JqAIhslaS\nf42hn4qpI+rWqMK40d54J7+AVwKBgQDaaQ9bTVge1L5Hwm1CVKRsf4Pwm8rMjzCq\n07W+1PW24Lo8QrijGJ2Rq54/TX4MAuyEa4sn1OsJiSwtTbPKf6wfPc7CkfCp8Ww8\nU0rXqocRhvHKfB/ZsUYcSQKzROWalGrVp+40USQWdrCNilu6S+xM/Eh8B+Y7kWA1\ntDPB+dW8iwKBgDseQfqifyO8Ji32aZf2LwL8M06vBlJd282wiCdKC4AUfAdhPS5z\n9f4Y/QOYHCpMw/k7GVQkWqOoTpOoMakJf5w3abUM0I89lj9m7nkIuKPbSdaxxfjd\n5cOp0oOiSCm5R7ITK4ovB+Ehmhyq4AMlmgkvDPl30bvRF6MTpApzYmvVAoGBAIE5\n2BQ1VwYm6c6bgvnUCtUHPZGHHB6cOjdYvBgE+L0Tih1NfOFDFzexSxg5SXLh5/8R\ngmw21jn2J2VGrDIMCFMTxtnob3Sdm2S2A3pHM1NzfGxJtK6g7NKfgDGBejhTyEJR\n8eaSe7+uyhd03YEEmvOR8XExW0+zXDFqRZVntMaxAoGAM43u+BiwzZekAIsJNBNC\nEhquhfQqNC0shRcczXMqQpXy/koNFn6XXXY8m1U5gj+m4F3Id2h3Jh8QnOVS0xhW\n//G0M5N9sgcDS8h42OyUIRtSHUAhAs2dHIdPC/daHc6g3+imqMize2Yjk3FxRGNC\n0sngPVVAzRu1ju/72y864gc=\n-----END PRIVATE KEY-----\n",
|
||||||
|
"client_email": "firebase-adminsdk-puz9e@de-iot.iam.gserviceaccount.com",
|
||||||
|
"client_id": "104801381442509062654",
|
||||||
|
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
"token_uri": "https://oauth2.googleapis.com/token",
|
||||||
|
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||||
|
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-puz9e%40de-iot.iam.gserviceaccount.com"
|
||||||
|
}
|
||||||
201
IoT-Node/server.js
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
let express = require('express')
|
||||||
|
let logger = require('morgan')
|
||||||
|
let bodyParser = require('body-parser')
|
||||||
|
let admin = require("firebase-admin");
|
||||||
|
let serviceAccount = require("./secrets/de-iot-firebase-adminsdk-puz9e-be74faaf8c.json");
|
||||||
|
|
||||||
|
let firebaseadmin = admin.initializeApp({
|
||||||
|
credential: admin.credential.cert(serviceAccount),
|
||||||
|
databaseURL: "https://de-iot.firebaseio.com"
|
||||||
|
})
|
||||||
|
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
let db = admin.firestore();
|
||||||
|
let FieldValue = require('firebase-admin').firestore.FieldValue;
|
||||||
|
let auth = admin.auth();
|
||||||
|
|
||||||
|
let app = express()
|
||||||
|
app.use(bodyParser.json())
|
||||||
|
app.use(bodyParser.urlencoded({extended: true}))
|
||||||
|
app.use(logger('dev'))
|
||||||
|
app.use(express.static('views'))
|
||||||
|
|
||||||
|
app.set('view engine', 'ejs')
|
||||||
|
app.set('views', __dirname + '/views')
|
||||||
|
|
||||||
|
|
||||||
|
app.get('/', function(request, responce){
|
||||||
|
responce.render('index.ejs')
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
app.post('/submit', function(request, responce){
|
||||||
|
if (dataValidation(request)) {
|
||||||
|
let uid = authCheck(request)
|
||||||
|
if (uid) {
|
||||||
|
let data = {
|
||||||
|
timestamp: FieldValue.serverTimestamp(),
|
||||||
|
value1: request.body.var1,
|
||||||
|
value2: Number(request.body.var2),
|
||||||
|
uploader: uid
|
||||||
|
}
|
||||||
|
db.collection('logs').doc().set(data)
|
||||||
|
.then(function(){
|
||||||
|
responce.send({success:true, error:null})
|
||||||
|
})
|
||||||
|
.catch(e => (console.log(e)))
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responce.send({success:false, error:"Auth Error"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responce.send({success:false, error:"Data Validation"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/light', async function(request, responce){
|
||||||
|
if (dataVal5(request)) {
|
||||||
|
let uid = await authCheck(request)
|
||||||
|
if (uid) {
|
||||||
|
let data = {
|
||||||
|
isOn: s2b(request.body.state),
|
||||||
|
brightness: Number(request.body.brightness),
|
||||||
|
color: String(request.body.color),
|
||||||
|
lastChangedBy: uid
|
||||||
|
}
|
||||||
|
.then(function(){
|
||||||
|
responce.send({success:true, error:null})
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.log(e)
|
||||||
|
responce.send({success:false, error:"Internal, " + e})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responce.send({success:false, error:"Auth Error"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responce.send({success:false, error:"Data Validation"})
|
||||||
|
console.log(request.body)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/zlight', async function(request, responce){
|
||||||
|
let isOn = s2b(request.body.state)
|
||||||
|
let brightness = Number(request.body.brightness)
|
||||||
|
let color = Number(request.body.color)
|
||||||
|
let sendD = {
|
||||||
|
brightness: brightness,
|
||||||
|
temperature: color,
|
||||||
|
transition_period: 250,
|
||||||
|
power: isOn
|
||||||
|
}
|
||||||
|
console.log(sendD)
|
||||||
|
|
||||||
|
axios.post('http://192.168.1.175:8080/api/v1/devices/local/led/brightness', sendD)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(`statusCode: ${res.statusCode}`)
|
||||||
|
responce.send({success:true})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
app.post('/gst-debug', async function(request, responce){
|
||||||
|
db.collection('apiData').doc('light').get()
|
||||||
|
.then(doc => {
|
||||||
|
let data = doc.data()
|
||||||
|
responce.send({success:true, state:data.isOn})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/get-api', async function(request, responce){
|
||||||
|
if (dataVal6(request)) {
|
||||||
|
let uid = await authCheck(request)
|
||||||
|
if (uid) {
|
||||||
|
var targetService = String(request.body.service)
|
||||||
|
db.collection('apiData').doc(targetService).get()
|
||||||
|
.then(doc => {
|
||||||
|
if (!doc.exists) {
|
||||||
|
responce.send({success:false, error:"Service does not exist"})
|
||||||
|
} else {
|
||||||
|
responce.send({success:true, data:doc.data()})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
responce.send({success:false, error:"Internal, " + e})
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responce.send({success:false, error:"Auth Error"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responce.send({success:false, error:"Data Validation"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function dataValidation(data){
|
||||||
|
if (data.body.var1) {
|
||||||
|
if (data.body.var2) {
|
||||||
|
if (Number(data.body.var2)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function dataVal6(data){
|
||||||
|
if (String(data.body.service) && String(data.body.authToken)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function dataVal5(data){
|
||||||
|
if ((data.body.state == 'true' || data.body.state == 'false') && Number(data.body.brightness) && String(data.body.color) && String(data.body.authToken)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function s2b(string){
|
||||||
|
switch(string.toLowerCase().trim()){
|
||||||
|
case "true": case "yes": case 'on': case "1": return true
|
||||||
|
case "false": case "no": case 'off': case "0": case null: return false
|
||||||
|
default: return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function authCheck(data) {
|
||||||
|
let uid = false
|
||||||
|
console.log(data.body.authToken)
|
||||||
|
decodedToken = await admin.auth().verifyIdToken(data.body.authToken).catch(e=>{console.log(e)})
|
||||||
|
uid = decodedToken.uid
|
||||||
|
return uid
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
app.get('*', function(request, responce){
|
||||||
|
responce.render('404.ejs')
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('*', function(request, responce){
|
||||||
|
responce.status(404).send({success:false, error:"404"})
|
||||||
|
})
|
||||||
|
|
||||||
|
var port = 5050
|
||||||
|
|
||||||
|
app.listen(port, function() {
|
||||||
|
console.log('Server running on port ' + port)
|
||||||
|
})
|
||||||
20
IoT-Node/views/404.ejs
Normal file
17
IoT-Node/views/css/style.css
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
main svg {
|
||||||
|
position: relative;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: #D8D8D8;
|
||||||
|
text-align: center;
|
||||||
|
height: 50px;
|
||||||
|
font-size: 25px;
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
20
IoT-Node/views/index.ejs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||||
|
<script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-app.js"></script>
|
||||||
|
<script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-analytics.js"></script>
|
||||||
|
<script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-firestore.js"></script>
|
||||||
|
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="chart"></div>
|
||||||
|
|
||||||
|
<div style="position: relative; left: 40%; font-size: 50px;">
|
||||||
|
<div style="height: 50px;"></div>
|
||||||
|
<div id="light">Light:Object</div>
|
||||||
|
</div>
|
||||||
|
<script defer src="js/main.js"></script>
|
||||||
|
<script src="js/fInit.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
13
IoT-Node/views/js/fInit.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
var firebaseConfig = {
|
||||||
|
apiKey: "AIzaSyD1jAfJ2M6InT2lMQfDghQMDZofWIP3eL4",
|
||||||
|
authDomain: "de-iot.firebaseapp.com",
|
||||||
|
databaseURL: "https://de-iot.firebaseio.com",
|
||||||
|
projectId: "de-iot",
|
||||||
|
storageBucket: "de-iot.appspot.com",
|
||||||
|
messagingSenderId: "706842395090",
|
||||||
|
appId: "1:706842395090:web:4149e14f67759d01b8880b",
|
||||||
|
measurementId: "G-P0MEBRLNHW"
|
||||||
|
};
|
||||||
|
// Initialize Firebase
|
||||||
|
firebase.initializeApp(firebaseConfig);
|
||||||
|
firebase.analytics();
|
||||||
99
IoT-Node/views/js/main.js
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
let db = firebase.firestore()
|
||||||
|
|
||||||
|
var logRef = db.collection("logs")
|
||||||
|
|
||||||
|
// var ySeries = []
|
||||||
|
// var querySnapshot = await logRef.get()
|
||||||
|
// querySnapshot.forEach((doc) => {
|
||||||
|
// var docData = doc.data()
|
||||||
|
// console.log("Document data:", docData)
|
||||||
|
// ySeries.push(docData.value2)
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
function init(){
|
||||||
|
var ySeries = []
|
||||||
|
logRef.orderBy("timestamp", "asc").get().then(querySnapshot=> {
|
||||||
|
querySnapshot.forEach((doc) => {
|
||||||
|
var docData = doc.data()
|
||||||
|
console.log("Val ", docData.value2)
|
||||||
|
ySeries.push(docData.value2)
|
||||||
|
})
|
||||||
|
createGraph(ySeries)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function createGraph(yArray){
|
||||||
|
var trace1 = {
|
||||||
|
type: 'line',
|
||||||
|
y: yArray,
|
||||||
|
name: "Marker One",
|
||||||
|
marker: {
|
||||||
|
color: '#77EEEE',
|
||||||
|
line: {
|
||||||
|
width: 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var data = [ trace1 ]
|
||||||
|
|
||||||
|
var layout = {
|
||||||
|
title: 'Graph 1',
|
||||||
|
font: {size: 18}
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = {responsive: true}
|
||||||
|
|
||||||
|
Plotly.newPlot('chart', data, layout, config)
|
||||||
|
}
|
||||||
|
|
||||||
|
init()
|
||||||
|
|
||||||
|
var counter = 0
|
||||||
|
logRef.onSnapshot(function(querySnapshot) {
|
||||||
|
var updates = querySnapshot.docChanges()
|
||||||
|
if (updates.length < 5){
|
||||||
|
updates.forEach(function(change) {
|
||||||
|
var docData = change.doc.data()
|
||||||
|
Plotly.extendTraces('chart', {y:[[docData.value2]]}, [0])
|
||||||
|
counter++
|
||||||
|
if (counter > 50) {
|
||||||
|
Plotly.relayout('chart', {
|
||||||
|
xaxis: {
|
||||||
|
range: [counter - 50, counter]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function realtimeUpdates(){
|
||||||
|
let apiRef = db.collection("apiData")
|
||||||
|
let toggleDiv = document.getElementById('toggle')
|
||||||
|
let intensityDiv = document.getElementById('intensity')
|
||||||
|
let colorDiv = document.getElementById('color')
|
||||||
|
let lightDiv = document.getElementById('light')
|
||||||
|
|
||||||
|
apiRef.doc("toggle").onSnapshot(function(doc) {
|
||||||
|
var data = doc.data()
|
||||||
|
toggleDiv.innerHTML = "Toggle: " + data.state
|
||||||
|
})
|
||||||
|
|
||||||
|
apiRef.doc("intensity").onSnapshot(function(doc) {
|
||||||
|
var data = doc.data()
|
||||||
|
intensityDiv.innerHTML = "Intensity: " + data.value
|
||||||
|
})
|
||||||
|
|
||||||
|
apiRef.doc("color").onSnapshot(function(doc) {
|
||||||
|
var data = doc.data()
|
||||||
|
colorDiv.innerHTML = "Color: " + data.hex
|
||||||
|
})
|
||||||
|
|
||||||
|
apiRef.doc("light").onSnapshot(function(doc) {
|
||||||
|
var data = doc.data()
|
||||||
|
lightDiv.innerHTML = "Object Light:<div style='padding-left: 20px;'>State: "+data.isOn+"<br>Color: "+data.color+"<br>Intensity: "+data.brightness+"</div>"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
realtimeUpdates()
|
||||||
0
IoT-Python/Icon
Normal file
77
IoT-Python/main.py
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import firebase_admin, threading
|
||||||
|
from firebase_admin import credentials
|
||||||
|
from firebase_admin import firestore
|
||||||
|
|
||||||
|
class Light:
|
||||||
|
def __init__(self):
|
||||||
|
self.state = False
|
||||||
|
self.brightness = 0
|
||||||
|
self.colour = '000000'
|
||||||
|
self.cred = credentials.Certificate("secrets/de-iot-firebase-adminsdk-puz9e-7388634d69.json")
|
||||||
|
firebase_admin.initialize_app(self.cred)
|
||||||
|
self.db = firestore.client()
|
||||||
|
self.callback_done = threading.Event()
|
||||||
|
self.apiMonitor()
|
||||||
|
|
||||||
|
def apiMonitor(self):
|
||||||
|
self.doc_ref = self.db.collection(u'apiData').document(u'light')
|
||||||
|
self.doc_watch = self.doc_ref.on_snapshot(self.on_snapshot)
|
||||||
|
|
||||||
|
def on_snapshot(self, doc_snapshot, changes, read_time):
|
||||||
|
for doc in doc_snapshot:
|
||||||
|
if doc.id == 'light':
|
||||||
|
print('|')
|
||||||
|
doc = doc.to_dict()
|
||||||
|
state = doc['isOn']
|
||||||
|
brightness = doc['brightness']
|
||||||
|
colour = doc['color']
|
||||||
|
self.update(state=state, brightness=brightness, colour=colour)
|
||||||
|
self.callback_done.set()
|
||||||
|
|
||||||
|
|
||||||
|
def update(self, state=False, brightness=0, colour='000000'):
|
||||||
|
self.state = state
|
||||||
|
self.brightness = brightness
|
||||||
|
self.colour = colour
|
||||||
|
self.updateHW()
|
||||||
|
|
||||||
|
def updateHW(self):
|
||||||
|
print("Sending HW state: " + str(self.state))
|
||||||
|
self.changeState(self.state)
|
||||||
|
print("Sending HW brightness: " + str(self.state))
|
||||||
|
self.changeBrightness(self.brightness)
|
||||||
|
print("Sending HW colour: " + str(self.state))
|
||||||
|
self.changeColour(self.colour)
|
||||||
|
|
||||||
|
def changeState(self, state):
|
||||||
|
print("Toggling FET to: " + str(self.state))
|
||||||
|
|
||||||
|
def changeBrightness(self, brightness):
|
||||||
|
print("Toggling Brightness PWM to: " + str(brightness))
|
||||||
|
|
||||||
|
def changeColour(self, colour):
|
||||||
|
print("Toggling Colour to RGB: ", tuple(int(colour[i:i+2], 16) for i in (0, 2, 4)))
|
||||||
|
|
||||||
|
light = Light()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"type": "service_account",
|
||||||
|
"project_id": "de-iot",
|
||||||
|
"private_key_id": "7388634d69c21f7fdc6b8e73ba729e9fa593d1aa",
|
||||||
|
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDQeVauUzDp4YFQ\nW+l6tuLTbBOrw9srFjm813CGUTCrErrq88NtmfNa4x/JV/SdEn4eTRwp/beUavFI\nXPJm+07H704bVuiYye8tp6lngiTXfOiExKB5ekW9k174pcmt33ZaSL07ov0sB8oj\nWHH0JQM/A9cb8fDNI4ESm1OUnQSsMJ1WTHEoBmpKrW0xPkRwPGIxXswSkGjfTefP\nCCNitvcd2+j6bpvGRa5RmOviTpaWzk9QpLwpCxOOl74HXV8up27fAAzn9HJJa+FU\nuQ65gfN5Oj2lZvYnMTe1gex1BMXgPrPAazCKfXxDnIToKsSGacpwdcnhlqzqP7+w\nwv9nmsidAgMBAAECggEACbmjWMoCNeLibq5+943JCo5X45MlKf8lLeFJ+0YV1GEx\nDY1WEEqWfuaqALFE9L/cWMsFlZLjqb2MaHEHkNTH4c1Q0jctbhU7fmB8J1s7nz7R\nNQJcLxaMYtHZZBWN0TnjskYC5+GMWG27mQcC993zJxEli4TvlA5EMutCjKP/iA29\n9eJRPMZg1rFoP1P07gx85VrafTxcLg/SbYl8j6/1f6UXcXGF51gsv0mJPOgSqqHl\nAr09ud7Z9FdE7fApVN1eVbvUsinSXYE5u1vUffUB+t96dwVgQH7mTZ2k5ubSuQ0H\n4pduxE2PKsffitGFs16gxss4RoazymADX9/8ZUNHAQKBgQDsi16YOQkpTvEO+PIt\nZcNIscbJaw0wR+tIbdhGN70w1xpDc1GJ6LfSPznH4xk68f+msHbkdfZYNRsUKRMX\nhuRs/38VEwTH/9/9drnRFDA6+awYNzlEpiZ2ieXQAWJeCBa8+cp/IQrRSY/caEqP\nraAv3r1lgS2yPrV5Y83wSQEvnQKBgQDhnux/WZMhc3TyXrb05bhYavP8XeFDUOac\ngKhfMcGtWz48yvaFvtESEDZxb546/Z/cDIhSUhaGnz2hSfy35oEyDeEaKe0WgkUC\nXFk6GteDoR2ekxkiaTo/1vqKz6QHLrJCIKM3iUgst5offgyVp2s+IcQxZyxu01S0\ndsC+YLctAQKBgHsI4uL6h7FcxjWrdwv16mVdUrBhZjK+tbqup9eeFmHZAGglCzxY\nN4S8LimyDeWDCh6BmtWqJcArnzIVS0DpgNbQ7iDgC5Sbmr4TiwMdJRkH1GOkFb2H\nTmpJv6c5kRinzGvu4UzOuvmw8YsLE/03qiI8EPdDAam8xFenee6JinxhAoGBANVY\nJQPLHPBtr7Eb1N9Adg/NmscRstenoVlt40iY0S5u8CwmM/SGWkY9ZG3hgPsBJu+6\nPhGxo7FK1Mk2IC15XsOJEkleSd2V81FnJ8xk41OJv2taZ1L9s+H4E9O8wrsz8cXL\n/Oqf+sqmFqwe0iGVPTh0T4PzrrVhSmCXRmz/IVcBAoGBAIxDzFyMtBGCh0K15Sd1\n1fL368HecawORWbjPaYJ9T+lHrPIck6DJvUBtH8h7V/b/s2IEV6wxxx9Wl6NUTax\nNBgxg8f72cw+7YvnUCQlDbaOdLLA90vmnqCe2r/VuVD1Kmz6KGWfhAKIOCqz58tC\nfN/wlq9N/oY0WoWb9/YGdYQV\n-----END PRIVATE KEY-----\n",
|
||||||
|
"client_email": "firebase-adminsdk-puz9e@de-iot.iam.gserviceaccount.com",
|
||||||
|
"client_id": "104801381442509062654",
|
||||||
|
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
"token_uri": "https://oauth2.googleapis.com/token",
|
||||||
|
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||||
|
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-puz9e%40de-iot.iam.gserviceaccount.com"
|
||||||
|
}
|
||||||
381
IoT-iOS/.gitignore
vendored
Normal file
@ -0,0 +1,381 @@
|
|||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/macos,xcode,swift,python,node
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,xcode,swift,python,node
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
### Node ###
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
.env*.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
pytestdebug.log
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
doc/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
pythonenv*
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# profiling data
|
||||||
|
.prof
|
||||||
|
|
||||||
|
### Swift ###
|
||||||
|
# Xcode
|
||||||
|
#
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
## User settings
|
||||||
|
xcuserdata/
|
||||||
|
|
||||||
|
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||||
|
*.xcscmblueprint
|
||||||
|
*.xccheckout
|
||||||
|
|
||||||
|
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||||
|
DerivedData/
|
||||||
|
*.moved-aside
|
||||||
|
*.pbxuser
|
||||||
|
!default.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
!default.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
!default.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
!default.perspectivev3
|
||||||
|
|
||||||
|
## Obj-C/Swift specific
|
||||||
|
*.hmap
|
||||||
|
|
||||||
|
## App packaging
|
||||||
|
*.ipa
|
||||||
|
*.dSYM.zip
|
||||||
|
*.dSYM
|
||||||
|
|
||||||
|
## Playgrounds
|
||||||
|
timeline.xctimeline
|
||||||
|
playground.xcworkspace
|
||||||
|
|
||||||
|
# Swift Package Manager
|
||||||
|
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||||
|
# Packages/
|
||||||
|
# Package.pins
|
||||||
|
# Package.resolved
|
||||||
|
# *.xcodeproj
|
||||||
|
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
|
||||||
|
# hence it is not needed unless you have added a package configuration file to your project
|
||||||
|
# .swiftpm
|
||||||
|
|
||||||
|
.build/
|
||||||
|
|
||||||
|
# CocoaPods
|
||||||
|
# We recommend against adding the Pods directory to your .gitignore. However
|
||||||
|
# you should judge for yourself, the pros and cons are mentioned at:
|
||||||
|
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||||
|
# Pods/
|
||||||
|
# Add this line if you want to avoid checking in source code from the Xcode workspace
|
||||||
|
# *.xcworkspace
|
||||||
|
|
||||||
|
# Carthage
|
||||||
|
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||||
|
# Carthage/Checkouts
|
||||||
|
|
||||||
|
Carthage/Build/
|
||||||
|
|
||||||
|
# Accio dependency management
|
||||||
|
Dependencies/
|
||||||
|
.accio/
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
# It is recommended to not store the screenshots in the git repo.
|
||||||
|
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
|
||||||
|
# For more information about the recommended setup visit:
|
||||||
|
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||||
|
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/Preview.html
|
||||||
|
fastlane/screenshots/**/*.png
|
||||||
|
fastlane/test_output
|
||||||
|
|
||||||
|
# Code Injection
|
||||||
|
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||||
|
# https://github.com/johnno1962/injectionforxcode
|
||||||
|
|
||||||
|
iOSInjectionProject/
|
||||||
|
|
||||||
|
### Xcode ###
|
||||||
|
# Xcode
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Gcc Patch
|
||||||
|
/*.gcno
|
||||||
|
|
||||||
|
### Xcode Patch ###
|
||||||
|
*.xcodeproj/*
|
||||||
|
!*.xcodeproj/project.pbxproj
|
||||||
|
!*.xcodeproj/xcshareddata/
|
||||||
|
!*.xcworkspace/contents.xcworkspacedata
|
||||||
|
**/xcshareddata/WorkspaceSettings.xcsettings
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/macos,xcode,swift,python,node
|
||||||
615
IoT-iOS/Firebase test.xcodeproj/project.pbxproj
Normal file
@ -0,0 +1,615 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 51;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
501A572E2469B1BB009C7EDA /* ColorWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501A572D2469B1BB009C7EDA /* ColorWheel.swift */; };
|
||||||
|
5035AFC42472FA8B0098D23C /* XUITEST.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5035AFC32472FA8B0098D23C /* XUITEST.swift */; };
|
||||||
|
503D51102462DB8500E7DFE9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503D510F2462DB8500E7DFE9 /* AppDelegate.swift */; };
|
||||||
|
503D51122462DB8500E7DFE9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503D51112462DB8500E7DFE9 /* SceneDelegate.swift */; };
|
||||||
|
503D51142462DB8500E7DFE9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503D51132462DB8500E7DFE9 /* ViewController.swift */; };
|
||||||
|
503D51172462DB8500E7DFE9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 503D51152462DB8500E7DFE9 /* Main.storyboard */; };
|
||||||
|
503D51192462DB8600E7DFE9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 503D51182462DB8600E7DFE9 /* Assets.xcassets */; };
|
||||||
|
503D511C2462DB8600E7DFE9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 503D511A2462DB8600E7DFE9 /* LaunchScreen.storyboard */; };
|
||||||
|
503D51242462DBD300E7DFE9 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 503D51232462DBD300E7DFE9 /* GoogleService-Info.plist */; };
|
||||||
|
503D51262462F6ED00E7DFE9 /* SignUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503D51252462F6ED00E7DFE9 /* SignUpViewController.swift */; };
|
||||||
|
503D51282462F70F00E7DFE9 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503D51272462F70F00E7DFE9 /* LoginViewController.swift */; };
|
||||||
|
503D512A2462F72300E7DFE9 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503D51292462F72300E7DFE9 /* HomeViewController.swift */; };
|
||||||
|
503D512D246317AD00E7DFE9 /* constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503D512C246317AD00E7DFE9 /* constants.swift */; };
|
||||||
|
92D3C78ED1B70F6DF97873A0 /* Pods_XUITEST.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCD72207409741738E8C6672 /* Pods_XUITEST.framework */; };
|
||||||
|
FA2B9BDA466613864C24D848 /* Pods_Firebase_test.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F9A9CDA4F9A5AADBE3B5BE /* Pods_Firebase_test.framework */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
5035AFC62472FA8B0098D23C /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 503D51042462DB8500E7DFE9 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 503D510B2462DB8500E7DFE9;
|
||||||
|
remoteInfo = "Firebase test";
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
28F9A9CDA4F9A5AADBE3B5BE /* Pods_Firebase_test.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firebase_test.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
2E7FE0C7AD9F9C62D817FABC /* Pods-XUITEST.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XUITEST.release.xcconfig"; path = "Target Support Files/Pods-XUITEST/Pods-XUITEST.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
413E25E3DF43D5B07F7635A1 /* Pods-Firebase test.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firebase test.debug.xcconfig"; path = "Target Support Files/Pods-Firebase test/Pods-Firebase test.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
501A572D2469B1BB009C7EDA /* ColorWheel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWheel.swift; sourceTree = "<group>"; };
|
||||||
|
5035AFC12472FA8B0098D23C /* XUITEST.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XUITEST.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
5035AFC32472FA8B0098D23C /* XUITEST.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XUITEST.swift; sourceTree = "<group>"; };
|
||||||
|
5035AFC52472FA8B0098D23C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
503D510C2462DB8500E7DFE9 /* Iot Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Iot Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
503D510F2462DB8500E7DFE9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
503D51112462DB8500E7DFE9 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
503D51132462DB8500E7DFE9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||||
|
503D51162462DB8500E7DFE9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||||
|
503D51182462DB8600E7DFE9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
503D511B2462DB8600E7DFE9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
|
503D511D2462DB8600E7DFE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
503D51232462DBD300E7DFE9 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
|
||||||
|
503D51252462F6ED00E7DFE9 /* SignUpViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpViewController.swift; sourceTree = "<group>"; };
|
||||||
|
503D51272462F70F00E7DFE9 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
|
||||||
|
503D51292462F72300E7DFE9 /* HomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = "<group>"; };
|
||||||
|
503D512C246317AD00E7DFE9 /* constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = constants.swift; sourceTree = "<group>"; };
|
||||||
|
6EA4B8846B80A588300D16A1 /* Pods-Firebase test.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firebase test.release.xcconfig"; path = "Target Support Files/Pods-Firebase test/Pods-Firebase test.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
97F49410260C8426F868054E /* Pods-XUITEST.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XUITEST.debug.xcconfig"; path = "Target Support Files/Pods-XUITEST/Pods-XUITEST.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
FCD72207409741738E8C6672 /* Pods_XUITEST.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_XUITEST.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
5035AFBE2472FA8B0098D23C /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
92D3C78ED1B70F6DF97873A0 /* Pods_XUITEST.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
503D51092462DB8500E7DFE9 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
FA2B9BDA466613864C24D848 /* Pods_Firebase_test.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
5035AFC22472FA8B0098D23C /* XUITEST */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
5035AFC32472FA8B0098D23C /* XUITEST.swift */,
|
||||||
|
5035AFC52472FA8B0098D23C /* Info.plist */,
|
||||||
|
);
|
||||||
|
path = XUITEST;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
503D51032462DB8500E7DFE9 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
503D510E2462DB8500E7DFE9 /* Firebase test */,
|
||||||
|
5035AFC22472FA8B0098D23C /* XUITEST */,
|
||||||
|
503D510D2462DB8500E7DFE9 /* Products */,
|
||||||
|
57B9C6DFA957486CF917FA7A /* Pods */,
|
||||||
|
C78ACBEE89FF382B677CD535 /* Frameworks */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
503D510D2462DB8500E7DFE9 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
503D510C2462DB8500E7DFE9 /* Iot Demo.app */,
|
||||||
|
5035AFC12472FA8B0098D23C /* XUITEST.xctest */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
503D510E2462DB8500E7DFE9 /* Firebase test */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
503D51132462DB8500E7DFE9 /* ViewController.swift */,
|
||||||
|
503D51252462F6ED00E7DFE9 /* SignUpViewController.swift */,
|
||||||
|
503D51272462F70F00E7DFE9 /* LoginViewController.swift */,
|
||||||
|
503D51292462F72300E7DFE9 /* HomeViewController.swift */,
|
||||||
|
503D51232462DBD300E7DFE9 /* GoogleService-Info.plist */,
|
||||||
|
503D510F2462DB8500E7DFE9 /* AppDelegate.swift */,
|
||||||
|
503D51112462DB8500E7DFE9 /* SceneDelegate.swift */,
|
||||||
|
503D51152462DB8500E7DFE9 /* Main.storyboard */,
|
||||||
|
503D51182462DB8600E7DFE9 /* Assets.xcassets */,
|
||||||
|
503D511A2462DB8600E7DFE9 /* LaunchScreen.storyboard */,
|
||||||
|
503D511D2462DB8600E7DFE9 /* Info.plist */,
|
||||||
|
503D512C246317AD00E7DFE9 /* constants.swift */,
|
||||||
|
501A572D2469B1BB009C7EDA /* ColorWheel.swift */,
|
||||||
|
);
|
||||||
|
path = "Firebase test";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
57B9C6DFA957486CF917FA7A /* Pods */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
413E25E3DF43D5B07F7635A1 /* Pods-Firebase test.debug.xcconfig */,
|
||||||
|
6EA4B8846B80A588300D16A1 /* Pods-Firebase test.release.xcconfig */,
|
||||||
|
97F49410260C8426F868054E /* Pods-XUITEST.debug.xcconfig */,
|
||||||
|
2E7FE0C7AD9F9C62D817FABC /* Pods-XUITEST.release.xcconfig */,
|
||||||
|
);
|
||||||
|
path = Pods;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C78ACBEE89FF382B677CD535 /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
28F9A9CDA4F9A5AADBE3B5BE /* Pods_Firebase_test.framework */,
|
||||||
|
FCD72207409741738E8C6672 /* Pods_XUITEST.framework */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
5035AFC02472FA8B0098D23C /* XUITEST */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 5035AFC82472FA8B0098D23C /* Build configuration list for PBXNativeTarget "XUITEST" */;
|
||||||
|
buildPhases = (
|
||||||
|
E387711A58E47620BEA643B2 /* [CP] Check Pods Manifest.lock */,
|
||||||
|
5035AFBD2472FA8B0098D23C /* Sources */,
|
||||||
|
5035AFBE2472FA8B0098D23C /* Frameworks */,
|
||||||
|
5035AFBF2472FA8B0098D23C /* Resources */,
|
||||||
|
829322F317DC20A82E32610F /* [CP] Embed Pods Frameworks */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
5035AFC72472FA8B0098D23C /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = XUITEST;
|
||||||
|
productName = XUITEST;
|
||||||
|
productReference = 5035AFC12472FA8B0098D23C /* XUITEST.xctest */;
|
||||||
|
productType = "com.apple.product-type.bundle.ui-testing";
|
||||||
|
};
|
||||||
|
503D510B2462DB8500E7DFE9 /* Firebase test */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 503D51202462DB8600E7DFE9 /* Build configuration list for PBXNativeTarget "Firebase test" */;
|
||||||
|
buildPhases = (
|
||||||
|
F3541C5BBD63626279FABD89 /* [CP] Check Pods Manifest.lock */,
|
||||||
|
503D51082462DB8500E7DFE9 /* Sources */,
|
||||||
|
503D51092462DB8500E7DFE9 /* Frameworks */,
|
||||||
|
503D510A2462DB8500E7DFE9 /* Resources */,
|
||||||
|
E1A1E13CBCA69D2CAD8C06FE /* [CP] Embed Pods Frameworks */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = "Firebase test";
|
||||||
|
productName = "Firebase test";
|
||||||
|
productReference = 503D510C2462DB8500E7DFE9 /* Iot Demo.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
503D51042462DB8500E7DFE9 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastSwiftUpdateCheck = 1140;
|
||||||
|
LastUpgradeCheck = 1140;
|
||||||
|
ORGANIZATIONNAME = smt;
|
||||||
|
TargetAttributes = {
|
||||||
|
5035AFC02472FA8B0098D23C = {
|
||||||
|
CreatedOnToolsVersion = 11.4.1;
|
||||||
|
TestTargetID = 503D510B2462DB8500E7DFE9;
|
||||||
|
};
|
||||||
|
503D510B2462DB8500E7DFE9 = {
|
||||||
|
CreatedOnToolsVersion = 11.4.1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 503D51072462DB8500E7DFE9 /* Build configuration list for PBXProject "Firebase test" */;
|
||||||
|
compatibilityVersion = "Xcode 9.3";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 503D51032462DB8500E7DFE9;
|
||||||
|
productRefGroup = 503D510D2462DB8500E7DFE9 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
503D510B2462DB8500E7DFE9 /* Firebase test */,
|
||||||
|
5035AFC02472FA8B0098D23C /* XUITEST */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
5035AFBF2472FA8B0098D23C /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
503D510A2462DB8500E7DFE9 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
503D511C2462DB8600E7DFE9 /* LaunchScreen.storyboard in Resources */,
|
||||||
|
503D51242462DBD300E7DFE9 /* GoogleService-Info.plist in Resources */,
|
||||||
|
503D51192462DB8600E7DFE9 /* Assets.xcassets in Resources */,
|
||||||
|
503D51172462DB8500E7DFE9 /* Main.storyboard in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
|
829322F317DC20A82E32610F /* [CP] Embed Pods Frameworks */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
"${PODS_ROOT}/Target Support Files/Pods-XUITEST/Pods-XUITEST-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
|
);
|
||||||
|
name = "[CP] Embed Pods Frameworks";
|
||||||
|
outputFileListPaths = (
|
||||||
|
"${PODS_ROOT}/Target Support Files/Pods-XUITEST/Pods-XUITEST-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-XUITEST/Pods-XUITEST-frameworks.sh\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
E1A1E13CBCA69D2CAD8C06FE /* [CP] Embed Pods Frameworks */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
"${PODS_ROOT}/Target Support Files/Pods-Firebase test/Pods-Firebase test-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
|
);
|
||||||
|
name = "[CP] Embed Pods Frameworks";
|
||||||
|
outputFileListPaths = (
|
||||||
|
"${PODS_ROOT}/Target Support Files/Pods-Firebase test/Pods-Firebase test-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Firebase test/Pods-Firebase test-frameworks.sh\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
E387711A58E47620BEA643B2 /* [CP] Check Pods Manifest.lock */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||||
|
"${PODS_ROOT}/Manifest.lock",
|
||||||
|
);
|
||||||
|
name = "[CP] Check Pods Manifest.lock";
|
||||||
|
outputFileListPaths = (
|
||||||
|
);
|
||||||
|
outputPaths = (
|
||||||
|
"$(DERIVED_FILE_DIR)/Pods-XUITEST-checkManifestLockResult.txt",
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
F3541C5BBD63626279FABD89 /* [CP] Check Pods Manifest.lock */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||||
|
"${PODS_ROOT}/Manifest.lock",
|
||||||
|
);
|
||||||
|
name = "[CP] Check Pods Manifest.lock";
|
||||||
|
outputFileListPaths = (
|
||||||
|
);
|
||||||
|
outputPaths = (
|
||||||
|
"$(DERIVED_FILE_DIR)/Pods-Firebase test-checkManifestLockResult.txt",
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
5035AFBD2472FA8B0098D23C /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
5035AFC42472FA8B0098D23C /* XUITEST.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
503D51082462DB8500E7DFE9 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
503D51142462DB8500E7DFE9 /* ViewController.swift in Sources */,
|
||||||
|
503D51102462DB8500E7DFE9 /* AppDelegate.swift in Sources */,
|
||||||
|
503D51262462F6ED00E7DFE9 /* SignUpViewController.swift in Sources */,
|
||||||
|
503D512D246317AD00E7DFE9 /* constants.swift in Sources */,
|
||||||
|
503D51282462F70F00E7DFE9 /* LoginViewController.swift in Sources */,
|
||||||
|
503D51122462DB8500E7DFE9 /* SceneDelegate.swift in Sources */,
|
||||||
|
503D512A2462F72300E7DFE9 /* HomeViewController.swift in Sources */,
|
||||||
|
501A572E2469B1BB009C7EDA /* ColorWheel.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
5035AFC72472FA8B0098D23C /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = 503D510B2462DB8500E7DFE9 /* Firebase test */;
|
||||||
|
targetProxy = 5035AFC62472FA8B0098D23C /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
503D51152462DB8500E7DFE9 /* Main.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
503D51162462DB8500E7DFE9 /* Base */,
|
||||||
|
);
|
||||||
|
name = Main.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
503D511A2462DB8600E7DFE9 /* LaunchScreen.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
503D511B2462DB8600E7DFE9 /* Base */,
|
||||||
|
);
|
||||||
|
name = LaunchScreen.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
5035AFC92472FA8B0098D23C /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 97F49410260C8426F868054E /* Pods-XUITEST.debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = 36JR976L6Y;
|
||||||
|
INFOPLIST_FILE = XUITEST/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
"@loader_path/Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = ac.smt.XUITEST;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_TARGET_NAME = "Firebase test";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
5035AFCA2472FA8B0098D23C /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 2E7FE0C7AD9F9C62D817FABC /* Pods-XUITEST.release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = 36JR976L6Y;
|
||||||
|
INFOPLIST_FILE = XUITEST/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
"@loader_path/Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = ac.smt.XUITEST;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_TARGET_NAME = "Firebase test";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
503D511E2462DB8600E7DFE9 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
503D511F2462DB8600E7DFE9 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
503D51212462DB8600E7DFE9 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 413E25E3DF43D5B07F7635A1 /* Pods-Firebase test.debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = 36JR976L6Y;
|
||||||
|
INFOPLIST_FILE = "Firebase test/Info.plist";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 13.1;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = ac.mh.iot;
|
||||||
|
PRODUCT_NAME = "Iot Demo";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
503D51222462DB8600E7DFE9 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 6EA4B8846B80A588300D16A1 /* Pods-Firebase test.release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = 36JR976L6Y;
|
||||||
|
INFOPLIST_FILE = "Firebase test/Info.plist";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 13.1;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = ac.mh.iot;
|
||||||
|
PRODUCT_NAME = "Iot Demo";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
5035AFC82472FA8B0098D23C /* Build configuration list for PBXNativeTarget "XUITEST" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
5035AFC92472FA8B0098D23C /* Debug */,
|
||||||
|
5035AFCA2472FA8B0098D23C /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
503D51072462DB8500E7DFE9 /* Build configuration list for PBXProject "Firebase test" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
503D511E2462DB8600E7DFE9 /* Debug */,
|
||||||
|
503D511F2462DB8600E7DFE9 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
503D51202462DB8600E7DFE9 /* Build configuration list for PBXNativeTarget "Firebase test" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
503D51212462DB8600E7DFE9 /* Debug */,
|
||||||
|
503D51222462DB8600E7DFE9 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 503D51042462DB8500E7DFE9 /* Project object */;
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>classNames</key>
|
||||||
|
<dict>
|
||||||
|
<key>XUITEST</key>
|
||||||
|
<dict>
|
||||||
|
<key>testLaunchPerformance()</key>
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.dt.XCTMetric_OSSignpost-AppLaunch.duration</key>
|
||||||
|
<dict>
|
||||||
|
<key>baselineAverage</key>
|
||||||
|
<real>2.92</real>
|
||||||
|
<key>baselineIntegrationDisplayName</key>
|
||||||
|
<string>Local Baseline</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>runDestinationsByUUID</key>
|
||||||
|
<dict>
|
||||||
|
<key>1B52471F-E875-4FF8-A402-B2F42319761C</key>
|
||||||
|
<dict>
|
||||||
|
<key>localComputer</key>
|
||||||
|
<dict>
|
||||||
|
<key>busSpeedInMHz</key>
|
||||||
|
<integer>100</integer>
|
||||||
|
<key>cpuCount</key>
|
||||||
|
<integer>1</integer>
|
||||||
|
<key>cpuKind</key>
|
||||||
|
<string>Quad-Core Intel Core i7</string>
|
||||||
|
<key>cpuSpeedInMHz</key>
|
||||||
|
<integer>3100</integer>
|
||||||
|
<key>logicalCPUCoresPerPackage</key>
|
||||||
|
<integer>8</integer>
|
||||||
|
<key>modelCode</key>
|
||||||
|
<string>MacBookPro14,3</string>
|
||||||
|
<key>physicalCPUCoresPerPackage</key>
|
||||||
|
<integer>4</integer>
|
||||||
|
<key>platformIdentifier</key>
|
||||||
|
<string>com.apple.platform.macosx</string>
|
||||||
|
</dict>
|
||||||
|
<key>targetArchitecture</key>
|
||||||
|
<string>x86_64</string>
|
||||||
|
<key>targetDevice</key>
|
||||||
|
<dict>
|
||||||
|
<key>modelCode</key>
|
||||||
|
<string>iPhone12,5</string>
|
||||||
|
<key>platformIdentifier</key>
|
||||||
|
<string>com.apple.platform.iphonesimulator</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1140"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "503D510B2462DB8500E7DFE9"
|
||||||
|
BuildableName = "Iot Demo.app"
|
||||||
|
BlueprintName = "Firebase test"
|
||||||
|
ReferencedContainer = "container:Firebase test.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5035AFB22472FA630098D23C"
|
||||||
|
BuildableName = "Iot DemoUITests.xctest"
|
||||||
|
BlueprintName = "Iot DemoUITests"
|
||||||
|
ReferencedContainer = "container:Firebase test.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5035AFC02472FA8B0098D23C"
|
||||||
|
BuildableName = "XUITEST.xctest"
|
||||||
|
BlueprintName = "XUITEST"
|
||||||
|
ReferencedContainer = "container:Firebase test.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "503D510B2462DB8500E7DFE9"
|
||||||
|
BuildableName = "Iot Demo.app"
|
||||||
|
BlueprintName = "Firebase test"
|
||||||
|
ReferencedContainer = "container:Firebase test.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "503D510B2462DB8500E7DFE9"
|
||||||
|
BuildableName = "Iot Demo.app"
|
||||||
|
BlueprintName = "Firebase test"
|
||||||
|
ReferencedContainer = "container:Firebase test.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1140"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5039A9DC2472F61B000319DB"
|
||||||
|
BuildableName = "Iot DemoUITests.xctest"
|
||||||
|
BlueprintName = "Iot DemoUITests"
|
||||||
|
ReferencedContainer = "container:Firebase test.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1140"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5035AFC02472FA8B0098D23C"
|
||||||
|
BuildableName = "XUITEST.xctest"
|
||||||
|
BlueprintName = "XUITEST"
|
||||||
|
ReferencedContainer = "container:Firebase test.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
10
IoT-iOS/Firebase test.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:Firebase test.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:Pods/Pods.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
39
IoT-iOS/Firebase test/AppDelegate.swift
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// AppDelegate.swift
|
||||||
|
// Firebase test
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 06/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import Firebase
|
||||||
|
|
||||||
|
@UIApplicationMain
|
||||||
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
// Override point for customization after application launch.
|
||||||
|
FirebaseApp.configure()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: UISceneSession Lifecycle
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||||
|
// Called when a new scene session is being created.
|
||||||
|
// Use this method to select a configuration to create the new scene with.
|
||||||
|
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||||
|
}
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||||
|
// Called when the user discards a scene session.
|
||||||
|
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||||
|
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,116 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-20@2x.png",
|
||||||
|
"scale": "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-20@3x.png",
|
||||||
|
"scale": "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-20.png",
|
||||||
|
"scale": "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-20@2x.png",
|
||||||
|
"scale": "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-29@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-40@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-60@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-60@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-29.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-40.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-76.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-76@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "83.5x83.5",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-83.5@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "1024x1024",
|
||||||
|
"idiom" : "ios-marketing",
|
||||||
|
"filename" : "IOT-LOGO-final_transparent-03-1024.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 11 KiB |
6
IoT-iOS/Firebase test/Assets.xcassets/Contents.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
29
IoT-iOS/Firebase test/Base.lproj/LaunchScreen.storyboard
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<accessibility key="accessibilityConfiguration">
|
||||||
|
<bool key="isElement" value="YES"/>
|
||||||
|
</accessibility>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
362
IoT-iOS/Firebase test/Base.lproj/Main.storyboard
Normal file
@ -0,0 +1,362 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="2Ix-Hv-yr5">
|
||||||
|
<device id="retina6_5" orientation="portrait" appearance="dark"/>
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="tne-QT-ifu">
|
||||||
|
<objects>
|
||||||
|
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Iot_Demo" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="aXb-0O-4PK">
|
||||||
|
<rect key="frame" x="40" y="732" width="334" height="90"/>
|
||||||
|
<subviews>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gnR-Ev-ZOR">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="334" height="40"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="height" constant="40" id="WJS-PJ-xdu"/>
|
||||||
|
</constraints>
|
||||||
|
<state key="normal" title="Login"/>
|
||||||
|
<connections>
|
||||||
|
<segue destination="4RA-yp-9fK" kind="show" id="2Oh-VT-2fO"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aM4-lx-xbN">
|
||||||
|
<rect key="frame" x="0.0" y="60" width="334" height="30"/>
|
||||||
|
<state key="normal" title="SIgn Up"/>
|
||||||
|
<connections>
|
||||||
|
<segue destination="Z09-3o-i9c" kind="show" id="JjE-vv-s46"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="aM4-lx-xbN" firstAttribute="height" secondItem="gnR-Ev-ZOR" secondAttribute="height" multiplier="0.75" id="ftJ-Sn-EKc"/>
|
||||||
|
</constraints>
|
||||||
|
</stackView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="aXb-0O-4PK" secondAttribute="trailing" constant="40" id="EYd-hI-cOa"/>
|
||||||
|
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="aXb-0O-4PK" secondAttribute="bottom" constant="40" id="Gys-Zy-nzv"/>
|
||||||
|
<constraint firstItem="aXb-0O-4PK" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="40" id="dd7-qJ-lHf"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="Ybk-bK-Bps"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="loginBtn" destination="gnR-Ev-ZOR" id="Gy7-4g-fNS"/>
|
||||||
|
<outlet property="signupBtn" destination="aM4-lx-xbN" id="BTE-bO-dIO"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="1047.8260869565217" y="115.84821428571428"/>
|
||||||
|
</scene>
|
||||||
|
<!--Login View Controller-->
|
||||||
|
<scene sceneID="UbM-eX-J1F">
|
||||||
|
<objects>
|
||||||
|
<viewController id="4RA-yp-9fK" customClass="LoginViewController" customModule="Iot_Demo" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Vn1-gH-4pJ">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="PaV-kR-R6b">
|
||||||
|
<rect key="frame" x="40" y="84.000000000000014" width="334" height="188.33333333333337"/>
|
||||||
|
<subviews>
|
||||||
|
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Email" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="0Jy-Fj-9Wv">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="334" height="34"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits"/>
|
||||||
|
</textField>
|
||||||
|
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Dux-Y8-p8o">
|
||||||
|
<rect key="frame" x="0.0" y="54" width="334" height="34"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits" returnKeyType="go" secureTextEntry="YES" textContentType="password"/>
|
||||||
|
</textField>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IjU-w2-mzJ">
|
||||||
|
<rect key="frame" x="0.0" y="108" width="334" height="40"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="height" constant="40" id="76U-zg-Ub3"/>
|
||||||
|
</constraints>
|
||||||
|
<state key="normal" title="Log In"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="loginTapped:" destination="4RA-yp-9fK" eventType="touchUpInside" id="AAk-Su-57L"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Error: nil" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="7" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="122-LT-UvJ">
|
||||||
|
<rect key="frame" x="0.0" y="168" width="334" height="20.333333333333343"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<color key="textColor" systemColor="systemRedColor" red="1" green="0.23137254900000001" blue="0.18823529410000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</stackView>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="PaV-kR-R6b" firstAttribute="top" secondItem="40Q-4i-l4Q" secondAttribute="top" constant="40" id="Gfm-GH-6Mr"/>
|
||||||
|
<constraint firstItem="PaV-kR-R6b" firstAttribute="leading" secondItem="40Q-4i-l4Q" secondAttribute="leading" constant="40" id="OhZ-eQ-xQS"/>
|
||||||
|
<constraint firstItem="40Q-4i-l4Q" firstAttribute="trailing" secondItem="PaV-kR-R6b" secondAttribute="trailing" constant="40" id="oLd-vg-Wi7"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="40Q-4i-l4Q"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="OCf-sE-Qii"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="email" destination="0Jy-Fj-9Wv" id="Fze-4n-nlH"/>
|
||||||
|
<outlet property="errLbl" destination="122-LT-UvJ" id="iRD-BC-Qp4"/>
|
||||||
|
<outlet property="logInBtn" destination="IjU-w2-mzJ" id="whY-IH-Ijf"/>
|
||||||
|
<outlet property="pwd" destination="Dux-Y8-p8o" id="2xd-v6-BUb"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="rh7-t6-H2L" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="1929" y="-282"/>
|
||||||
|
</scene>
|
||||||
|
<!--Sign Up View Controller-->
|
||||||
|
<scene sceneID="Oek-v2-nqb">
|
||||||
|
<objects>
|
||||||
|
<viewController id="Z09-3o-i9c" customClass="SignUpViewController" customModule="Iot_Demo" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="64i-fU-UDO">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="MQW-lb-A6N">
|
||||||
|
<rect key="frame" x="40" y="84" width="334" height="296.33333333333331"/>
|
||||||
|
<subviews>
|
||||||
|
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="First" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="GZv-9H-YB8">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="334" height="34"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits"/>
|
||||||
|
</textField>
|
||||||
|
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Last" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="5Oe-ay-ijh">
|
||||||
|
<rect key="frame" x="0.0" y="54" width="334" height="34"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits"/>
|
||||||
|
</textField>
|
||||||
|
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Email" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="vqS-OI-veI">
|
||||||
|
<rect key="frame" x="0.0" y="108" width="334" height="34"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits"/>
|
||||||
|
</textField>
|
||||||
|
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qxF-gh-z5Z">
|
||||||
|
<rect key="frame" x="0.0" y="162" width="334" height="34"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits" textContentType="new-password"/>
|
||||||
|
</textField>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iIW-bw-Eud">
|
||||||
|
<rect key="frame" x="0.0" y="216" width="334" height="40"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="height" constant="40" id="ZMM-9t-cc4"/>
|
||||||
|
</constraints>
|
||||||
|
<state key="normal" title="Sign Up"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="signUpTapped:" destination="Z09-3o-i9c" eventType="touchUpInside" id="ehP-hK-gpe"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Error: nil" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="7" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MbS-Pn-hlo">
|
||||||
|
<rect key="frame" x="0.0" y="276" width="334" height="20.333333333333314"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<color key="textColor" systemColor="systemRedColor" red="1" green="0.23137254900000001" blue="0.18823529410000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</stackView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<accessibility key="accessibilityConfiguration">
|
||||||
|
<bool key="isElement" value="YES"/>
|
||||||
|
</accessibility>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="MQW-lb-A6N" firstAttribute="leading" secondItem="d43-AW-suJ" secondAttribute="leading" constant="40" id="8hs-bg-Y4d"/>
|
||||||
|
<constraint firstItem="d43-AW-suJ" firstAttribute="trailing" secondItem="MQW-lb-A6N" secondAttribute="trailing" constant="40" id="LPB-wy-Vqe"/>
|
||||||
|
<constraint firstItem="MQW-lb-A6N" firstAttribute="top" secondItem="d43-AW-suJ" secondAttribute="top" constant="40" id="PR3-cc-TnQ"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="d43-AW-suJ"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="Tj8-cw-t9y"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="email" destination="vqS-OI-veI" id="Uuk-QS-mGJ"/>
|
||||||
|
<outlet property="errLbl" destination="MbS-Pn-hlo" id="fSD-Yy-tv3"/>
|
||||||
|
<outlet property="fName" destination="GZv-9H-YB8" id="bY9-dG-98P"/>
|
||||||
|
<outlet property="lName" destination="5Oe-ay-ijh" id="BCf-NZ-U6v"/>
|
||||||
|
<outlet property="pwd" destination="qxF-gh-z5Z" id="4OF-BH-wQW"/>
|
||||||
|
<outlet property="signUpBtn" destination="iIW-bw-Eud" id="BGY-hl-AOF"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="Zom-ma-ixE" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="1929" y="417"/>
|
||||||
|
</scene>
|
||||||
|
<!--Home View Controller-->
|
||||||
|
<scene sceneID="m0I-le-BlB">
|
||||||
|
<objects>
|
||||||
|
<viewController storyboardIdentifier="HomeVC" useStoryboardIdentifierAsRestorationIdentifier="YES" id="djB-Cc-nmz" customClass="HomeViewController" customModule="Iot_Demo" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="q8y-It-D7G">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Welcome, x" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QmQ-pX-vSj">
|
||||||
|
<rect key="frame" x="153.33333333333334" y="64" width="107.33333333333334" height="24"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="State" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hRg-Fc-1Bf">
|
||||||
|
<rect key="frame" x="20" y="140" width="41" height="21"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Brightness" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Aoc-Jo-b2r">
|
||||||
|
<rect key="frame" x="20" y="200" width="82" height="21"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" restorationIdentifier="sw1" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vvY-L9-XYU" userLabel="sw1">
|
||||||
|
<rect key="frame" x="345" y="135" width="49" height="31"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<accessibility key="accessibilityConfiguration" identifier="id1" label="lbln"/>
|
||||||
|
<userDefinedRuntimeAttributes>
|
||||||
|
<userDefinedRuntimeAttribute type="boolean" keyPath="isAccessibilityElement" value="YES"/>
|
||||||
|
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityLabel" value="onSwitch"/>
|
||||||
|
</userDefinedRuntimeAttributes>
|
||||||
|
<connections>
|
||||||
|
<action selector="switchToggled:" destination="djB-Cc-nmz" eventType="valueChanged" id="qVZ-gg-AX6"/>
|
||||||
|
</connections>
|
||||||
|
</switch>
|
||||||
|
<slider opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="100" minValue="0.0" maxValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="ikv-m4-OD1">
|
||||||
|
<rect key="frame" x="125" y="200" width="269" height="30"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="bChanged1:" destination="djB-Cc-nmz" eventType="touchUpInside" id="HYj-Ra-WzW"/>
|
||||||
|
<action selector="bChanged2:" destination="djB-Cc-nmz" eventType="touchUpOutside" id="TOz-aF-pOW"/>
|
||||||
|
<action selector="bChanged3:" destination="djB-Cc-nmz" eventType="valueChanged" id="JoG-J6-oVW"/>
|
||||||
|
</connections>
|
||||||
|
</slider>
|
||||||
|
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dmR-s7-HZM">
|
||||||
|
<rect key="frame" x="20" y="96" width="374" height="21"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<color key="textColor" systemColor="systemRedColor" red="1" green="0.23137254900000001" blue="0.18823529410000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<view contentMode="center" horizontalHuggingPriority="750" verticalHuggingPriority="750" horizontalCompressionResistancePriority="749" verticalCompressionResistancePriority="749" fixedFrame="YES" preservesSuperviewLayoutMargins="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Thx-J4-Ccl" customClass="ColorWheel" customModule="Iot_Demo" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="20" y="308" width="280" height="280"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<gestureRecognizers/>
|
||||||
|
<userDefinedRuntimeAttributes>
|
||||||
|
<userDefinedRuntimeAttribute type="size" keyPath="size">
|
||||||
|
<size key="value" width="280" height="280"/>
|
||||||
|
</userDefinedRuntimeAttribute>
|
||||||
|
</userDefinedRuntimeAttributes>
|
||||||
|
<connections>
|
||||||
|
<outletCollection property="gestureRecognizers" destination="SVJ-45-7na" appends="YES" id="0NC-JQ-rCx"/>
|
||||||
|
<outletCollection property="gestureRecognizers" destination="EFW-il-40w" appends="YES" id="K5d-r8-8Yt"/>
|
||||||
|
</connections>
|
||||||
|
</view>
|
||||||
|
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KAP-JI-fM3" userLabel="Color Output">
|
||||||
|
<rect key="frame" x="20" y="608" width="88" height="88"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<color key="backgroundColor" red="0.66666668650000005" green="0.66666668650000005" blue="0.66666668650000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<gestureRecognizers/>
|
||||||
|
<connections>
|
||||||
|
<outletCollection property="gestureRecognizers" destination="iYE-SS-TI4" appends="YES" id="8d3-IG-2tX"/>
|
||||||
|
</connections>
|
||||||
|
</view>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Flood Requests (Dangerous!)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dR7-ig-QPw">
|
||||||
|
<rect key="frame" x="20" y="819" width="223" height="21"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Tgx-9E-DQP">
|
||||||
|
<rect key="frame" x="345" y="814" width="49" height="31"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="throttleToggled:" destination="djB-Cc-nmz" eventType="valueChanged" id="SxS-dL-ITm"/>
|
||||||
|
</connections>
|
||||||
|
</switch>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kzH-j5-Wus">
|
||||||
|
<rect key="frame" x="287" y="666" width="46" height="30"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<state key="normal" title="Button"/>
|
||||||
|
</button>
|
||||||
|
<slider opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="4600" minValue="2200" maxValue="7000" translatesAutoresizingMaskIntoConstraints="NO" id="eYG-ms-CIU">
|
||||||
|
<rect key="frame" x="18" y="245" width="378" height="30"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="cC1:" destination="djB-Cc-nmz" eventType="touchUpInside" id="02c-GX-ZT1"/>
|
||||||
|
<action selector="cC2:" destination="djB-Cc-nmz" eventType="touchDragOutside" id="eec-vn-8Lk"/>
|
||||||
|
</connections>
|
||||||
|
</slider>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<accessibility key="accessibilityConfiguration" identifier="vid1" label="viev1">
|
||||||
|
<accessibilityTraits key="traits" none="YES"/>
|
||||||
|
<bool key="isElement" value="NO"/>
|
||||||
|
</accessibility>
|
||||||
|
<viewLayoutGuide key="safeArea" id="WGb-Pd-Xnh"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="LFd-IH-da4"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="bSlider" destination="ikv-m4-OD1" id="fiS-lR-RXI"/>
|
||||||
|
<outlet property="cSlider" destination="eYG-ms-CIU" id="P76-sM-lcZ"/>
|
||||||
|
<outlet property="colorWheel" destination="Thx-J4-Ccl" id="NXT-6L-rGx"/>
|
||||||
|
<outlet property="colourOutput" destination="KAP-JI-fM3" id="JRB-Qb-5IH"/>
|
||||||
|
<outlet property="errorLbl" destination="dmR-s7-HZM" id="eWa-il-MK9"/>
|
||||||
|
<outlet property="onSwitch" destination="vvY-L9-XYU" id="LFK-uj-PcY"/>
|
||||||
|
<outlet property="welcomeLbl" destination="QmQ-pX-vSj" id="36W-0P-4Wg"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="yO3-xl-bFt" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||||
|
<tapGestureRecognizer id="SVJ-45-7na">
|
||||||
|
<connections>
|
||||||
|
<action selector="handleTapGesture:" destination="djB-Cc-nmz" id="xoR-oc-c4k"/>
|
||||||
|
</connections>
|
||||||
|
</tapGestureRecognizer>
|
||||||
|
<panGestureRecognizer minimumNumberOfTouches="1" id="EFW-il-40w">
|
||||||
|
<connections>
|
||||||
|
<action selector="handleDragGesture:" destination="djB-Cc-nmz" id="QLh-nI-f7B"/>
|
||||||
|
</connections>
|
||||||
|
</panGestureRecognizer>
|
||||||
|
<tapGestureRecognizer id="iYE-SS-TI4">
|
||||||
|
<connections>
|
||||||
|
<action selector="cPreviewTap:" destination="djB-Cc-nmz" id="tWR-Dm-5fe"/>
|
||||||
|
</connections>
|
||||||
|
</tapGestureRecognizer>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="2730.434782608696" y="115.84821428571428"/>
|
||||||
|
</scene>
|
||||||
|
<!--Navigation Controller-->
|
||||||
|
<scene sceneID="FSV-hd-F2t">
|
||||||
|
<objects>
|
||||||
|
<navigationController automaticallyAdjustsScrollViewInsets="NO" navigationBarHidden="YES" id="2Ix-Hv-yr5" sceneMemberID="viewController">
|
||||||
|
<toolbarItems/>
|
||||||
|
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="hWa-uz-Hww">
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</navigationBar>
|
||||||
|
<nil name="viewControllers"/>
|
||||||
|
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="ooQ-ng-ZvI">
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</toolbar>
|
||||||
|
<connections>
|
||||||
|
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="zZa-NI-8Dk"/>
|
||||||
|
</connections>
|
||||||
|
</navigationController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="eVc-Yd-3P5" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="137.68115942028987" y="115.84821428571428"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
80
IoT-iOS/Firebase test/ColorWheel.swift
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
|
struct ColorPath {
|
||||||
|
var Path:UIBezierPath
|
||||||
|
var Color:UIColor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@IBDesignable
|
||||||
|
class ColorWheel: UIView {
|
||||||
|
|
||||||
|
override init (frame : CGRect) {
|
||||||
|
super.init(frame : frame)
|
||||||
|
center = self.center
|
||||||
|
backgroundColor = UIColor(hue: 0, saturation: 0, brightness: 0, alpha: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
super.init(coder: aDecoder)
|
||||||
|
center = self.center
|
||||||
|
}
|
||||||
|
|
||||||
|
private var image:UIImage? = nil
|
||||||
|
private var imageView:UIImageView? = nil
|
||||||
|
private var paths = [ColorPath]()
|
||||||
|
|
||||||
|
@IBInspectable var size:CGSize = CGSize.zero { didSet { setNeedsDisplay()} }
|
||||||
|
@IBInspectable var sectors:Int = 360 { didSet { setNeedsDisplay()} }
|
||||||
|
|
||||||
|
func colorAtPoint ( point: CGPoint) -> UIColor {
|
||||||
|
for colorPath in 0..<paths.count {
|
||||||
|
if paths[colorPath].Path.contains(point) {
|
||||||
|
return paths[colorPath].Color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UIColor.clear
|
||||||
|
}
|
||||||
|
|
||||||
|
override func draw(_ rect: CGRect) {
|
||||||
|
|
||||||
|
let radius = CGFloat ( min(bounds.size.width, bounds.size.height) / 2.0 ) * 0.90
|
||||||
|
|
||||||
|
let angle:CGFloat = CGFloat(2.0) * (.pi) / CGFloat(sectors)
|
||||||
|
|
||||||
|
var colorPath:ColorPath = ColorPath(Path:UIBezierPath(), Color:UIColor.clear)
|
||||||
|
|
||||||
|
self.center = CGPoint(x: self.bounds.width - (self.bounds.width / 2.0),y: self.bounds.height - (self.bounds.height / 2.0) )
|
||||||
|
UIGraphicsBeginImageContextWithOptions(CGSize(width: bounds.size.width, height: bounds.size.height), true, 0)
|
||||||
|
|
||||||
|
UIColor.white.setFill()
|
||||||
|
UIRectFill(frame)
|
||||||
|
|
||||||
|
for sector in 0..<sectors {
|
||||||
|
let center = self.center
|
||||||
|
colorPath.Path = UIBezierPath(arcCenter: center, radius: radius, startAngle: CGFloat(sector) * angle, endAngle: (CGFloat(sector) + CGFloat(1)) * angle, clockwise: true)
|
||||||
|
colorPath.Path.addLine(to: center)
|
||||||
|
colorPath.Path.close()
|
||||||
|
|
||||||
|
let color = UIColor(hue: CGFloat(sector)/CGFloat(sectors), saturation: CGFloat(1), brightness: CGFloat(1), alpha: CGFloat(1))
|
||||||
|
color.setFill()
|
||||||
|
color.setStroke()
|
||||||
|
|
||||||
|
colorPath.Path.fill()
|
||||||
|
colorPath.Path.stroke()
|
||||||
|
colorPath.Color = color
|
||||||
|
|
||||||
|
paths.append(colorPath)
|
||||||
|
}
|
||||||
|
image = UIGraphicsGetImageFromCurrentImageContext()
|
||||||
|
UIGraphicsEndImageContext()
|
||||||
|
guard image != nil else { return }
|
||||||
|
let imageView = UIImageView (image: image)
|
||||||
|
self.addSubview(imageView)
|
||||||
|
guard let oc = superview?.center else { return }
|
||||||
|
self.center = oc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
36
IoT-iOS/Firebase test/GoogleService-Info.plist
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CLIENT_ID</key>
|
||||||
|
<string>706842395090-2n8kl2iiukc4j80qiqldv3mkj9vb8hc4.apps.googleusercontent.com</string>
|
||||||
|
<key>REVERSED_CLIENT_ID</key>
|
||||||
|
<string>com.googleusercontent.apps.706842395090-2n8kl2iiukc4j80qiqldv3mkj9vb8hc4</string>
|
||||||
|
<key>API_KEY</key>
|
||||||
|
<string>AIzaSyBJI0TYV912w_zwctExAR_-jaw_81Uvelk</string>
|
||||||
|
<key>GCM_SENDER_ID</key>
|
||||||
|
<string>706842395090</string>
|
||||||
|
<key>PLIST_VERSION</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>BUNDLE_ID</key>
|
||||||
|
<string>ac.mh.iot</string>
|
||||||
|
<key>PROJECT_ID</key>
|
||||||
|
<string>de-iot</string>
|
||||||
|
<key>STORAGE_BUCKET</key>
|
||||||
|
<string>de-iot.appspot.com</string>
|
||||||
|
<key>IS_ADS_ENABLED</key>
|
||||||
|
<false></false>
|
||||||
|
<key>IS_ANALYTICS_ENABLED</key>
|
||||||
|
<false></false>
|
||||||
|
<key>IS_APPINVITE_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>IS_GCM_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>IS_SIGNIN_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>GOOGLE_APP_ID</key>
|
||||||
|
<string>1:706842395090:ios:9409ca2caaf40058b8880b</string>
|
||||||
|
<key>DATABASE_URL</key>
|
||||||
|
<string>https://de-iot.firebaseio.com</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
174
IoT-iOS/Firebase test/HomeViewController.swift
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
//
|
||||||
|
// HomeViewController.swift
|
||||||
|
// Firebase test
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 06/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import FirebaseAuth
|
||||||
|
import SwiftyJSON
|
||||||
|
|
||||||
|
class HomeViewController: UIViewController {
|
||||||
|
@IBOutlet weak var welcomeLbl: UILabel!
|
||||||
|
@IBOutlet weak var onSwitch: UISwitch!
|
||||||
|
@IBOutlet weak var bSlider: UISlider!
|
||||||
|
@IBOutlet weak var errorLbl: UILabel!
|
||||||
|
@IBOutlet weak var colourOutput: UIView!
|
||||||
|
@IBOutlet weak var colorWheel: ColorWheel!
|
||||||
|
@IBOutlet weak var cSlider: UISlider!
|
||||||
|
|
||||||
|
var pColour = "000000"
|
||||||
|
var continousReq = false
|
||||||
|
var timer = Timer()
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
welcomeLbl.text = "Welcome, " + (Auth.auth().currentUser?.email)!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Do any additional setup after loading the view.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func apiCall(endpoint: String, data: [String : Any]){
|
||||||
|
let parameters = data
|
||||||
|
let url = URL(string: endpoint)! //change the url
|
||||||
|
let session = URLSession.shared
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
request.httpMethod = "POST" //set http method as POST
|
||||||
|
|
||||||
|
do {
|
||||||
|
request.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted) // pass dictionary to nsdata object and set it as request body
|
||||||
|
} catch let error {
|
||||||
|
print(error.localizedDescription)
|
||||||
|
}
|
||||||
|
|
||||||
|
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||||
|
request.addValue("application/json", forHTTPHeaderField: "Accept")
|
||||||
|
|
||||||
|
//create dataTask using the session object to send data to the server
|
||||||
|
let task = session.dataTask(with: request as URLRequest, completionHandler: { data, response, error in
|
||||||
|
|
||||||
|
guard error == nil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard let data = data else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
let responseJSON = try? JSON(data: data)
|
||||||
|
let status = responseJSON?["success"].stringValue
|
||||||
|
if status != "true"{
|
||||||
|
let err = responseJSON?["error"].stringValue
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.errorLbl.isHidden = false
|
||||||
|
self.errorLbl.text = err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
task.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func sendUpdate() {
|
||||||
|
let state = String(self.onSwitch.isOn)
|
||||||
|
let brightness = Int(self.bSlider.value)
|
||||||
|
let colour = Int(self.cSlider.value)
|
||||||
|
Auth.auth().currentUser?.getIDToken(completion: { (idToken, err) in
|
||||||
|
if err == nil, let token = idToken {
|
||||||
|
let parameters = ["state": state, "brightness":brightness, "color":colour, "authToken":token] as [String : Any]
|
||||||
|
let endpoint = "http://192.168.1.65:5050/zlight"
|
||||||
|
self.apiCall(endpoint: endpoint, data: parameters)
|
||||||
|
}else{
|
||||||
|
self.errorLbl.text = err?.localizedDescription
|
||||||
|
self.errorLbl.isHidden = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func u2h(colour:UIColor) -> String {
|
||||||
|
guard let components = colour.cgColor.components, components.count >= 3 else {
|
||||||
|
return "XERROR"
|
||||||
|
}
|
||||||
|
let r = Float(components[0])
|
||||||
|
let g = Float(components[1])
|
||||||
|
let b = Float(components[2])
|
||||||
|
return String(format: "%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255))
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// MARK: - Navigation
|
||||||
|
|
||||||
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||||
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||||
|
// Get the new view controller using segue.destination.
|
||||||
|
// Pass the selected object to the new view controller.
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
@IBAction func switchToggled(_ sender: Any) {
|
||||||
|
print("editing ended, state: ", onSwitch.isOn)
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
@IBAction func bChanged1(_ sender: Any) {
|
||||||
|
print("editing ended, value: ", bSlider.value)
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
@IBAction func bChanged2(_ sender: Any) {
|
||||||
|
print("editing ended, value: ", bSlider.value)
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
@IBAction func bChanged3(_ sender: Any) {
|
||||||
|
if (self.continousReq) {
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@IBAction func cC1(_ sender: Any) {
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
@IBAction func cC2(_ sender: Any) {
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
@IBAction func handleTapGesture(_ sender: UITapGestureRecognizer) {
|
||||||
|
let point = sender.location(in: colorWheel)
|
||||||
|
let colour = colorWheel.colorAtPoint(point: point)
|
||||||
|
colourOutput.backgroundColor = colour
|
||||||
|
self.pColour = u2h(colour: colour)
|
||||||
|
}
|
||||||
|
@IBAction func handleDragGesture(_ sender: UIPanGestureRecognizer) {
|
||||||
|
let point = sender.location(in: colorWheel)
|
||||||
|
let colour = colorWheel.colorAtPoint(point: point)
|
||||||
|
colourOutput.backgroundColor = colour
|
||||||
|
self.pColour = u2h(colour: colour)
|
||||||
|
if (self.continousReq) {
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@IBAction func cPreviewTap(_ sender: Any) {
|
||||||
|
sendUpdate()
|
||||||
|
}
|
||||||
|
@IBAction func throttleToggled(_ sender: UISwitch) {
|
||||||
|
self.continousReq = sender.isOn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extension UIColor {
|
||||||
|
convenience init(hexString: String, alpha: CGFloat = 1.0) {
|
||||||
|
let hexString: String = hexString.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
|
||||||
|
let scanner = Scanner(string: hexString)
|
||||||
|
var color: UInt64 = 0
|
||||||
|
scanner.scanHexInt64(&color)
|
||||||
|
let mask = 0x000000FF
|
||||||
|
let r = Int(color >> 16) & mask
|
||||||
|
let g = Int(color >> 8) & mask
|
||||||
|
let b = Int(color) & mask
|
||||||
|
let red = CGFloat(r) / 255.0
|
||||||
|
let green = CGFloat(g) / 255.0
|
||||||
|
let blue = CGFloat(b) / 255.0
|
||||||
|
self.init(red:red, green:green, blue:blue, alpha:alpha)
|
||||||
|
}
|
||||||
|
}
|
||||||
67
IoT-iOS/Firebase test/Info.plist
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSAppTransportSecurity</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>UIApplicationSceneManifest</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIApplicationSupportsMultipleScenes</key>
|
||||||
|
<false/>
|
||||||
|
<key>UISceneConfigurations</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIWindowSceneSessionRoleApplication</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UISceneConfigurationName</key>
|
||||||
|
<string>Default Configuration</string>
|
||||||
|
<key>UISceneDelegateClassName</key>
|
||||||
|
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||||
|
<key>UISceneStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>UIMainStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<array>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
55
IoT-iOS/Firebase test/LoginViewController.swift
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
//
|
||||||
|
// LoginViewController.swift
|
||||||
|
// Firebase test
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 06/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import FirebaseAuth
|
||||||
|
|
||||||
|
class LoginViewController: UIViewController {
|
||||||
|
|
||||||
|
@IBOutlet weak var email: UITextField!
|
||||||
|
@IBOutlet weak var pwd: UITextField!
|
||||||
|
@IBOutlet weak var logInBtn: UIButton!
|
||||||
|
@IBOutlet weak var errLbl: UILabel!
|
||||||
|
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
errLbl.isHidden = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
// MARK: - Navigation
|
||||||
|
|
||||||
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||||
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||||
|
// Get the new view controller using segue.destination.
|
||||||
|
// Pass the selected object to the new view controller.
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@IBAction func loginTapped(_ sender: Any) {
|
||||||
|
self.email.text = "superuser21@averylongdomain.com"
|
||||||
|
self.pwd.text = "123456"
|
||||||
|
Auth.auth().signIn(withEmail: self.email.text!, password: self.pwd.text!) { (result, err) in
|
||||||
|
if err != nil {
|
||||||
|
self.errLbl.isHidden = false
|
||||||
|
self.errLbl.text = err?.localizedDescription
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
let HomeViewController = self.storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
|
||||||
|
self.view.window?.rootViewController = HomeViewController
|
||||||
|
self.view.window?.makeKeyAndVisible()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
53
IoT-iOS/Firebase test/SceneDelegate.swift
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
// SceneDelegate.swift
|
||||||
|
// Firebase test
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 06/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
|
|
||||||
|
var window: UIWindow?
|
||||||
|
|
||||||
|
|
||||||
|
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||||
|
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||||
|
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||||
|
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||||
|
guard let _ = (scene as? UIWindowScene) else { return }
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidDisconnect(_ scene: UIScene) {
|
||||||
|
// Called as the scene is being released by the system.
|
||||||
|
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||||
|
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||||
|
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||||
|
// Called when the scene has moved from an inactive state to an active state.
|
||||||
|
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneWillResignActive(_ scene: UIScene) {
|
||||||
|
// Called when the scene will move from an active state to an inactive state.
|
||||||
|
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||||
|
// Called as the scene transitions from the background to the foreground.
|
||||||
|
// Use this method to undo the changes made on entering the background.
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||||
|
// Called as the scene transitions from the foreground to the background.
|
||||||
|
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||||
|
// to restore the scene back to its current state.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
69
IoT-iOS/Firebase test/SignUpViewController.swift
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
//
|
||||||
|
// SignUpViewController.swift
|
||||||
|
// Firebase test
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 06/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import FirebaseAuth
|
||||||
|
import Firebase
|
||||||
|
|
||||||
|
class SignUpViewController: UIViewController {
|
||||||
|
|
||||||
|
@IBOutlet weak var fName: UITextField!
|
||||||
|
@IBOutlet weak var lName: UITextField!
|
||||||
|
@IBOutlet weak var email: UITextField!
|
||||||
|
@IBOutlet weak var pwd: UITextField!
|
||||||
|
@IBOutlet weak var signUpBtn: UIButton!
|
||||||
|
@IBOutlet weak var errLbl: UILabel!
|
||||||
|
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
errLbl.isHidden = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
// MARK: - Navigation
|
||||||
|
|
||||||
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||||
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||||
|
// Get the new view controller using segue.destination.
|
||||||
|
// Pass the selected object to the new view controller.
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@IBAction func signUpTapped(_ sender: Any) {
|
||||||
|
Auth.auth().createUser(withEmail: self.email.text!, password: self.pwd.text!) { (result, err) in
|
||||||
|
if let err = err {
|
||||||
|
self.errLbl.isHidden = false
|
||||||
|
self.errLbl.text = err.localizedDescription
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let db = Firestore.firestore()
|
||||||
|
db.collection("users").addDocument(data: [
|
||||||
|
"First Name":self.fName.text!,
|
||||||
|
"Last Name":self.lName.text!,
|
||||||
|
"email":self.email.text!,
|
||||||
|
"uid":result!.user.uid
|
||||||
|
]) { (error) in
|
||||||
|
if error != nil {
|
||||||
|
self.errLbl.isHidden = false
|
||||||
|
self.errLbl.text = error!.localizedDescription
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let HomeViewController = self.storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
|
||||||
|
self.view.window?.rootViewController = HomeViewController
|
||||||
|
self.view.window?.makeKeyAndVisible()
|
||||||
|
//goto home
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
22
IoT-iOS/Firebase test/ViewController.swift
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// ViewController.swift
|
||||||
|
// Firebase test
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 06/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class ViewController: UIViewController {
|
||||||
|
@IBOutlet weak var loginBtn: UIButton!
|
||||||
|
@IBOutlet weak var signupBtn: UIButton!
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
// Do any additional setup after loading the view.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
15
IoT-iOS/Firebase test/constants.swift
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// constants.swift
|
||||||
|
// Firebase test
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 06/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct Constants {
|
||||||
|
struct Storyboard {
|
||||||
|
static let homeViewController = "HomeVC"
|
||||||
|
}
|
||||||
|
}
|
||||||
0
IoT-iOS/Icon
Normal file
22
IoT-iOS/Iot DemoUITests/Info.plist
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
43
IoT-iOS/Iot DemoUITests/Iot_DemoUITests.swift
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// Iot_DemoUITests.swift
|
||||||
|
// Iot DemoUITests
|
||||||
|
//
|
||||||
|
// Created by Max Hunt on 18/05/2020.
|
||||||
|
// Copyright © 2020 smt. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class Iot_DemoUITests: XCTestCase {
|
||||||
|
|
||||||
|
override func setUpWithError() throws {
|
||||||
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
|
|
||||||
|
// In UI tests it is usually best to stop immediately when a failure occurs.
|
||||||
|
continueAfterFailure = false
|
||||||
|
|
||||||
|
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tearDownWithError() throws {
|
||||||
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
func testExample() throws {
|
||||||
|
// UI tests must launch the application that they test.
|
||||||
|
let app = XCUIApplication()
|
||||||
|
app.launch()
|
||||||
|
|
||||||
|
// Use recording to get started writing UI tests.
|
||||||
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||||
|
}
|
||||||
|
|
||||||
|
func testLaunchPerformance() throws {
|
||||||
|
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) {
|
||||||
|
// This measures how long it takes to launch your application.
|
||||||
|
measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
|
||||||
|
XCUIApplication().launch()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
IoT-iOS/Podfile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Uncomment the next line to define a global platform for your project
|
||||||
|
# platform :ios, '9.0'
|
||||||
|
platform :ios, '13.1'
|
||||||
|
target 'Firebase test' do
|
||||||
|
# Comment the next line if you don't want to use dynamic frameworks
|
||||||
|
use_frameworks!
|
||||||
|
pod "Firebase/Analytics"
|
||||||
|
pod "Firebase/Auth"
|
||||||
|
pod "Firebase/Core"
|
||||||
|
pod "Firebase/Firestore"
|
||||||
|
pod 'SwiftyJSON', '~> 4.0'
|
||||||
|
# Pods for Firebase test
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
target 'XUITEST' do
|
||||||
|
# Comment the next line if you don't want to use dynamic frameworks
|
||||||
|
use_frameworks!
|
||||||
|
pod 'SwiftyJSON', '~> 4.0'
|
||||||
|
# Pods for Firebase test
|
||||||
|
|
||||||
|
end
|
||||||
401
IoT-iOS/Podfile.lock
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
PODS:
|
||||||
|
- abseil/algorithm (0.20200225.0):
|
||||||
|
- abseil/algorithm/algorithm (= 0.20200225.0)
|
||||||
|
- abseil/algorithm/container (= 0.20200225.0)
|
||||||
|
- abseil/algorithm/algorithm (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/algorithm/container (0.20200225.0):
|
||||||
|
- abseil/algorithm/algorithm
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/base (0.20200225.0):
|
||||||
|
- abseil/base/atomic_hook (= 0.20200225.0)
|
||||||
|
- abseil/base/base (= 0.20200225.0)
|
||||||
|
- abseil/base/base_internal (= 0.20200225.0)
|
||||||
|
- abseil/base/bits (= 0.20200225.0)
|
||||||
|
- abseil/base/config (= 0.20200225.0)
|
||||||
|
- abseil/base/core_headers (= 0.20200225.0)
|
||||||
|
- abseil/base/dynamic_annotations (= 0.20200225.0)
|
||||||
|
- abseil/base/endian (= 0.20200225.0)
|
||||||
|
- abseil/base/errno_saver (= 0.20200225.0)
|
||||||
|
- abseil/base/exponential_biased (= 0.20200225.0)
|
||||||
|
- abseil/base/log_severity (= 0.20200225.0)
|
||||||
|
- abseil/base/malloc_internal (= 0.20200225.0)
|
||||||
|
- abseil/base/periodic_sampler (= 0.20200225.0)
|
||||||
|
- abseil/base/pretty_function (= 0.20200225.0)
|
||||||
|
- abseil/base/raw_logging_internal (= 0.20200225.0)
|
||||||
|
- abseil/base/spinlock_wait (= 0.20200225.0)
|
||||||
|
- abseil/base/throw_delegate (= 0.20200225.0)
|
||||||
|
- abseil/base/atomic_hook (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/base (0.20200225.0):
|
||||||
|
- abseil/base/atomic_hook
|
||||||
|
- abseil/base/base_internal
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/dynamic_annotations
|
||||||
|
- abseil/base/log_severity
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/base/spinlock_wait
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/base/base_internal (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/base/bits (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/config (0.20200225.0)
|
||||||
|
- abseil/base/core_headers (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/dynamic_annotations (0.20200225.0)
|
||||||
|
- abseil/base/endian (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/errno_saver (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/exponential_biased (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/log_severity (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/malloc_internal (0.20200225.0):
|
||||||
|
- abseil/base/base
|
||||||
|
- abseil/base/base_internal
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/dynamic_annotations
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/base/periodic_sampler (0.20200225.0):
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/exponential_biased
|
||||||
|
- abseil/base/pretty_function (0.20200225.0)
|
||||||
|
- abseil/base/raw_logging_internal (0.20200225.0):
|
||||||
|
- abseil/base/atomic_hook
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/log_severity
|
||||||
|
- abseil/base/spinlock_wait (0.20200225.0):
|
||||||
|
- abseil/base/base_internal
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/errno_saver
|
||||||
|
- abseil/base/throw_delegate (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/container/compressed_tuple (0.20200225.0):
|
||||||
|
- abseil/utility/utility
|
||||||
|
- abseil/container/inlined_vector (0.20200225.0):
|
||||||
|
- abseil/algorithm/algorithm
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/throw_delegate
|
||||||
|
- abseil/container/inlined_vector_internal
|
||||||
|
- abseil/memory/memory
|
||||||
|
- abseil/container/inlined_vector_internal (0.20200225.0):
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/container/compressed_tuple
|
||||||
|
- abseil/memory/memory
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/types/span
|
||||||
|
- abseil/memory (0.20200225.0):
|
||||||
|
- abseil/memory/memory (= 0.20200225.0)
|
||||||
|
- abseil/memory/memory (0.20200225.0):
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/meta (0.20200225.0):
|
||||||
|
- abseil/meta/type_traits (= 0.20200225.0)
|
||||||
|
- abseil/meta/type_traits (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/numeric/int128 (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/strings/internal (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/endian
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/strings/str_format (0.20200225.0):
|
||||||
|
- abseil/strings/str_format_internal
|
||||||
|
- abseil/strings/str_format_internal (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/numeric/int128
|
||||||
|
- abseil/strings/strings
|
||||||
|
- abseil/types/span
|
||||||
|
- abseil/strings/strings (0.20200225.0):
|
||||||
|
- abseil/base/base
|
||||||
|
- abseil/base/bits
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/endian
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/base/throw_delegate
|
||||||
|
- abseil/memory/memory
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/numeric/int128
|
||||||
|
- abseil/strings/internal
|
||||||
|
- abseil/time (0.20200225.0):
|
||||||
|
- abseil/time/internal (= 0.20200225.0)
|
||||||
|
- abseil/time/time (= 0.20200225.0)
|
||||||
|
- abseil/time/internal (0.20200225.0):
|
||||||
|
- abseil/time/internal/cctz (= 0.20200225.0)
|
||||||
|
- abseil/time/internal/cctz (0.20200225.0):
|
||||||
|
- abseil/time/internal/cctz/civil_time (= 0.20200225.0)
|
||||||
|
- abseil/time/internal/cctz/time_zone (= 0.20200225.0)
|
||||||
|
- abseil/time/internal/cctz/civil_time (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/time/internal/cctz/time_zone (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/time/internal/cctz/civil_time
|
||||||
|
- abseil/time/time (0.20200225.0):
|
||||||
|
- abseil/base/base
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/numeric/int128
|
||||||
|
- abseil/strings/strings
|
||||||
|
- abseil/time/internal/cctz/civil_time
|
||||||
|
- abseil/time/internal/cctz/time_zone
|
||||||
|
- abseil/types (0.20200225.0):
|
||||||
|
- abseil/types/any (= 0.20200225.0)
|
||||||
|
- abseil/types/bad_any_cast (= 0.20200225.0)
|
||||||
|
- abseil/types/bad_any_cast_impl (= 0.20200225.0)
|
||||||
|
- abseil/types/bad_optional_access (= 0.20200225.0)
|
||||||
|
- abseil/types/bad_variant_access (= 0.20200225.0)
|
||||||
|
- abseil/types/compare (= 0.20200225.0)
|
||||||
|
- abseil/types/optional (= 0.20200225.0)
|
||||||
|
- abseil/types/span (= 0.20200225.0)
|
||||||
|
- abseil/types/variant (= 0.20200225.0)
|
||||||
|
- abseil/types/any (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/types/bad_any_cast
|
||||||
|
- abseil/utility/utility
|
||||||
|
- abseil/types/bad_any_cast (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/types/bad_any_cast_impl
|
||||||
|
- abseil/types/bad_any_cast_impl (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/types/bad_optional_access (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/types/bad_variant_access (0.20200225.0):
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/raw_logging_internal
|
||||||
|
- abseil/types/compare (0.20200225.0):
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/types/optional (0.20200225.0):
|
||||||
|
- abseil/base/base_internal
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/memory/memory
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/types/bad_optional_access
|
||||||
|
- abseil/utility/utility
|
||||||
|
- abseil/types/span (0.20200225.0):
|
||||||
|
- abseil/algorithm/algorithm
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/base/throw_delegate
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/types/variant (0.20200225.0):
|
||||||
|
- abseil/base/base_internal
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/base/core_headers
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- abseil/types/bad_variant_access
|
||||||
|
- abseil/utility/utility
|
||||||
|
- abseil/utility/utility (0.20200225.0):
|
||||||
|
- abseil/base/base_internal
|
||||||
|
- abseil/base/config
|
||||||
|
- abseil/meta/type_traits
|
||||||
|
- BoringSSL-GRPC (0.0.7):
|
||||||
|
- BoringSSL-GRPC/Implementation (= 0.0.7)
|
||||||
|
- BoringSSL-GRPC/Interface (= 0.0.7)
|
||||||
|
- BoringSSL-GRPC/Implementation (0.0.7):
|
||||||
|
- BoringSSL-GRPC/Interface (= 0.0.7)
|
||||||
|
- BoringSSL-GRPC/Interface (0.0.7)
|
||||||
|
- Firebase/Analytics (6.24.0):
|
||||||
|
- Firebase/Core
|
||||||
|
- Firebase/Auth (6.24.0):
|
||||||
|
- Firebase/CoreOnly
|
||||||
|
- FirebaseAuth (~> 6.5.3)
|
||||||
|
- Firebase/Core (6.24.0):
|
||||||
|
- Firebase/CoreOnly
|
||||||
|
- FirebaseAnalytics (= 6.5.0)
|
||||||
|
- Firebase/CoreOnly (6.24.0):
|
||||||
|
- FirebaseCore (= 6.7.0)
|
||||||
|
- Firebase/Firestore (6.24.0):
|
||||||
|
- Firebase/CoreOnly
|
||||||
|
- FirebaseFirestore (~> 1.13.0)
|
||||||
|
- FirebaseAnalytics (6.5.0):
|
||||||
|
- FirebaseCore (~> 6.7)
|
||||||
|
- FirebaseInstallations (~> 1.2)
|
||||||
|
- GoogleAppMeasurement (= 6.5.0)
|
||||||
|
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
|
||||||
|
- GoogleUtilities/MethodSwizzler (~> 6.0)
|
||||||
|
- GoogleUtilities/Network (~> 6.0)
|
||||||
|
- "GoogleUtilities/NSData+zlib (~> 6.0)"
|
||||||
|
- nanopb (~> 1.30905.0)
|
||||||
|
- FirebaseAuth (6.5.3):
|
||||||
|
- FirebaseAuthInterop (~> 1.0)
|
||||||
|
- FirebaseCore (~> 6.6)
|
||||||
|
- GoogleUtilities/AppDelegateSwizzler (~> 6.5)
|
||||||
|
- GoogleUtilities/Environment (~> 6.5)
|
||||||
|
- GTMSessionFetcher/Core (~> 1.1)
|
||||||
|
- FirebaseAuthInterop (1.1.0)
|
||||||
|
- FirebaseCore (6.7.0):
|
||||||
|
- FirebaseCoreDiagnostics (~> 1.3)
|
||||||
|
- FirebaseCoreDiagnosticsInterop (~> 1.2)
|
||||||
|
- GoogleUtilities/Environment (~> 6.5)
|
||||||
|
- GoogleUtilities/Logger (~> 6.5)
|
||||||
|
- FirebaseCoreDiagnostics (1.3.0):
|
||||||
|
- FirebaseCoreDiagnosticsInterop (~> 1.2)
|
||||||
|
- GoogleDataTransportCCTSupport (~> 3.1)
|
||||||
|
- GoogleUtilities/Environment (~> 6.5)
|
||||||
|
- GoogleUtilities/Logger (~> 6.5)
|
||||||
|
- nanopb (~> 1.30905.0)
|
||||||
|
- FirebaseCoreDiagnosticsInterop (1.2.0)
|
||||||
|
- FirebaseFirestore (1.13.0):
|
||||||
|
- abseil/algorithm (= 0.20200225.0)
|
||||||
|
- abseil/base (= 0.20200225.0)
|
||||||
|
- abseil/memory (= 0.20200225.0)
|
||||||
|
- abseil/meta (= 0.20200225.0)
|
||||||
|
- abseil/strings/strings (= 0.20200225.0)
|
||||||
|
- abseil/time (= 0.20200225.0)
|
||||||
|
- abseil/types (= 0.20200225.0)
|
||||||
|
- FirebaseAuthInterop (~> 1.0)
|
||||||
|
- FirebaseCore (~> 6.2)
|
||||||
|
- "gRPC-C++ (~> 1.28.0)"
|
||||||
|
- leveldb-library (~> 1.22)
|
||||||
|
- nanopb (~> 1.30905.0)
|
||||||
|
- FirebaseInstallations (1.2.0):
|
||||||
|
- FirebaseCore (~> 6.6)
|
||||||
|
- GoogleUtilities/Environment (~> 6.6)
|
||||||
|
- GoogleUtilities/UserDefaults (~> 6.6)
|
||||||
|
- PromisesObjC (~> 1.2)
|
||||||
|
- GoogleAppMeasurement (6.5.0):
|
||||||
|
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
|
||||||
|
- GoogleUtilities/MethodSwizzler (~> 6.0)
|
||||||
|
- GoogleUtilities/Network (~> 6.0)
|
||||||
|
- "GoogleUtilities/NSData+zlib (~> 6.0)"
|
||||||
|
- nanopb (~> 1.30905.0)
|
||||||
|
- GoogleDataTransport (6.1.0)
|
||||||
|
- GoogleDataTransportCCTSupport (3.1.0):
|
||||||
|
- GoogleDataTransport (~> 6.1)
|
||||||
|
- nanopb (~> 1.30905.0)
|
||||||
|
- GoogleUtilities/AppDelegateSwizzler (6.6.0):
|
||||||
|
- GoogleUtilities/Environment
|
||||||
|
- GoogleUtilities/Logger
|
||||||
|
- GoogleUtilities/Network
|
||||||
|
- GoogleUtilities/Environment (6.6.0):
|
||||||
|
- PromisesObjC (~> 1.2)
|
||||||
|
- GoogleUtilities/Logger (6.6.0):
|
||||||
|
- GoogleUtilities/Environment
|
||||||
|
- GoogleUtilities/MethodSwizzler (6.6.0):
|
||||||
|
- GoogleUtilities/Logger
|
||||||
|
- GoogleUtilities/Network (6.6.0):
|
||||||
|
- GoogleUtilities/Logger
|
||||||
|
- "GoogleUtilities/NSData+zlib"
|
||||||
|
- GoogleUtilities/Reachability
|
||||||
|
- "GoogleUtilities/NSData+zlib (6.6.0)"
|
||||||
|
- GoogleUtilities/Reachability (6.6.0):
|
||||||
|
- GoogleUtilities/Logger
|
||||||
|
- GoogleUtilities/UserDefaults (6.6.0):
|
||||||
|
- GoogleUtilities/Logger
|
||||||
|
- "gRPC-C++ (1.28.0)":
|
||||||
|
- "gRPC-C++/Implementation (= 1.28.0)"
|
||||||
|
- "gRPC-C++/Interface (= 1.28.0)"
|
||||||
|
- "gRPC-C++/Implementation (1.28.0)":
|
||||||
|
- abseil/container/inlined_vector (= 0.20200225.0)
|
||||||
|
- abseil/memory/memory (= 0.20200225.0)
|
||||||
|
- abseil/strings/str_format (= 0.20200225.0)
|
||||||
|
- abseil/strings/strings (= 0.20200225.0)
|
||||||
|
- abseil/types/optional (= 0.20200225.0)
|
||||||
|
- "gRPC-C++/Interface (= 1.28.0)"
|
||||||
|
- gRPC-Core (= 1.28.0)
|
||||||
|
- "gRPC-C++/Interface (1.28.0)"
|
||||||
|
- gRPC-Core (1.28.0):
|
||||||
|
- gRPC-Core/Implementation (= 1.28.0)
|
||||||
|
- gRPC-Core/Interface (= 1.28.0)
|
||||||
|
- gRPC-Core/Implementation (1.28.0):
|
||||||
|
- abseil/container/inlined_vector (= 0.20200225.0)
|
||||||
|
- abseil/memory/memory (= 0.20200225.0)
|
||||||
|
- abseil/strings/str_format (= 0.20200225.0)
|
||||||
|
- abseil/strings/strings (= 0.20200225.0)
|
||||||
|
- abseil/types/optional (= 0.20200225.0)
|
||||||
|
- BoringSSL-GRPC (= 0.0.7)
|
||||||
|
- gRPC-Core/Interface (= 1.28.0)
|
||||||
|
- gRPC-Core/Interface (1.28.0)
|
||||||
|
- GTMSessionFetcher/Core (1.4.0)
|
||||||
|
- leveldb-library (1.22)
|
||||||
|
- nanopb (1.30905.0):
|
||||||
|
- nanopb/decode (= 1.30905.0)
|
||||||
|
- nanopb/encode (= 1.30905.0)
|
||||||
|
- nanopb/decode (1.30905.0)
|
||||||
|
- nanopb/encode (1.30905.0)
|
||||||
|
- PromisesObjC (1.2.8)
|
||||||
|
- SwiftyJSON (4.3.0)
|
||||||
|
|
||||||
|
DEPENDENCIES:
|
||||||
|
- Firebase/Analytics
|
||||||
|
- Firebase/Auth
|
||||||
|
- Firebase/Core
|
||||||
|
- Firebase/Firestore
|
||||||
|
- SwiftyJSON (~> 4.0)
|
||||||
|
|
||||||
|
SPEC REPOS:
|
||||||
|
trunk:
|
||||||
|
- abseil
|
||||||
|
- BoringSSL-GRPC
|
||||||
|
- Firebase
|
||||||
|
- FirebaseAnalytics
|
||||||
|
- FirebaseAuth
|
||||||
|
- FirebaseAuthInterop
|
||||||
|
- FirebaseCore
|
||||||
|
- FirebaseCoreDiagnostics
|
||||||
|
- FirebaseCoreDiagnosticsInterop
|
||||||
|
- FirebaseFirestore
|
||||||
|
- FirebaseInstallations
|
||||||
|
- GoogleAppMeasurement
|
||||||
|
- GoogleDataTransport
|
||||||
|
- GoogleDataTransportCCTSupport
|
||||||
|
- GoogleUtilities
|
||||||
|
- "gRPC-C++"
|
||||||
|
- gRPC-Core
|
||||||
|
- GTMSessionFetcher
|
||||||
|
- leveldb-library
|
||||||
|
- nanopb
|
||||||
|
- PromisesObjC
|
||||||
|
- SwiftyJSON
|
||||||
|
|
||||||
|
SPEC CHECKSUMS:
|
||||||
|
abseil: 6c8eb7892aefa08d929b39f9bb108e5367e3228f
|
||||||
|
BoringSSL-GRPC: 8edf627ee524575e2f8d19d56f068b448eea3879
|
||||||
|
Firebase: b28e55c60efd98963cd9011fe2fac5a10c2ba124
|
||||||
|
FirebaseAnalytics: 7386fc2176e3f93ad8ef34b5b1f2b33a891e4962
|
||||||
|
FirebaseAuth: 7047aec89c0b17ecd924a550c853f0c27ac6015e
|
||||||
|
FirebaseAuthInterop: a0f37ae05833af156e72028f648d313f7e7592e9
|
||||||
|
FirebaseCore: e610482f64097b0e9f056cd97bc6b33dfabcbb6a
|
||||||
|
FirebaseCoreDiagnostics: 4a773a47bd83bbd5a9b1ccf1ce7caa8b2d535e67
|
||||||
|
FirebaseCoreDiagnosticsInterop: 296e2c5f5314500a850ad0b83e9e7c10b011a850
|
||||||
|
FirebaseFirestore: 35f8f67d7b25e4743c62ea6e46c38cafa8dc32b5
|
||||||
|
FirebaseInstallations: 2119fb3e46b0a88bfdbf12562f855ee3252462fa
|
||||||
|
GoogleAppMeasurement: 4c644d86835d827bab30ab6aabb9ecaf1f500735
|
||||||
|
GoogleDataTransport: f6f8eba931df03ebd2232ff4645aa85f8f47b5ab
|
||||||
|
GoogleDataTransportCCTSupport: d70a561f7d236af529fee598835caad5e25f6d3d
|
||||||
|
GoogleUtilities: 39530bc0ad980530298e9c4af8549e991fd033b1
|
||||||
|
"gRPC-C++": 2ea13a2e14f0b89991a0b4b0151e7c6a56319516
|
||||||
|
gRPC-Core: 325ba201411619a7302c621a1c8ee787719d4b9b
|
||||||
|
GTMSessionFetcher: 6f5c8abbab8a9bce4bb3f057e317728ec6182b10
|
||||||
|
leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7
|
||||||
|
nanopb: c43f40fadfe79e8b8db116583945847910cbabc9
|
||||||
|
PromisesObjC: c119f3cd559f50b7ae681fa59dc1acd19173b7e6
|
||||||
|
SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08
|
||||||
|
|
||||||
|
PODFILE CHECKSUM: fe74be54af3c3b2f6d86da07b49faf181531820a
|
||||||
|
|
||||||
|
COCOAPODS: 1.9.1
|
||||||
251
IoT-iOS/Pods/BoringSSL-GRPC/LICENSE
generated
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL
|
||||||
|
licensing. Files that are completely new have a Google copyright and an ISC
|
||||||
|
license. This license is reproduced at the bottom of this file.
|
||||||
|
|
||||||
|
Contributors to BoringSSL are required to follow the CLA rules for Chromium:
|
||||||
|
https://cla.developers.google.com/clas
|
||||||
|
|
||||||
|
Files in third_party/ have their own licenses, as described therein. The MIT
|
||||||
|
license, for third_party/fiat, which, unlike other third_party directories, is
|
||||||
|
compiled into non-test libraries, is included below.
|
||||||
|
|
||||||
|
The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the
|
||||||
|
OpenSSL License and the original SSLeay license apply to the toolkit. See below
|
||||||
|
for the actual license texts. Actually both licenses are BSD-style Open Source
|
||||||
|
licenses. In case of any license issues related to OpenSSL please contact
|
||||||
|
openssl-core@openssl.org.
|
||||||
|
|
||||||
|
The following are Google-internal bug numbers where explicit permission from
|
||||||
|
some authors is recorded for use of their work. (This is purely for our own
|
||||||
|
record keeping.)
|
||||||
|
27287199
|
||||||
|
27287880
|
||||||
|
27287883
|
||||||
|
|
||||||
|
OpenSSL License
|
||||||
|
---------------
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the OpenSSL Project
|
||||||
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||||
|
* endorse or promote products derived from this software without
|
||||||
|
* prior written permission. For written permission, please contact
|
||||||
|
* openssl-core@openssl.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "OpenSSL"
|
||||||
|
* nor may "OpenSSL" appear in their names without prior written
|
||||||
|
* permission of the OpenSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the OpenSSL Project
|
||||||
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This product includes cryptographic software written by Eric Young
|
||||||
|
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||||
|
* Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
Original SSLeay License
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
ISC license used for completely new code in BoringSSL:
|
||||||
|
|
||||||
|
/* Copyright (c) 2015, Google Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||||
|
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||||
|
|
||||||
|
|
||||||
|
The code in third_party/fiat carries the MIT license:
|
||||||
|
|
||||||
|
Copyright (c) 2015-2016 the fiat-crypto authors (see
|
||||||
|
https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS).
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
Licenses for support code
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Parts of the TLS test suite are under the Go license. This code is not included
|
||||||
|
in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so
|
||||||
|
distributing code linked against BoringSSL does not trigger this license:
|
||||||
|
|
||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
BoringSSL uses the Chromium test infrastructure to run a continuous build,
|
||||||
|
trybots etc. The scripts which manage this, and the script for generating build
|
||||||
|
metadata, are under the Chromium license. Distributing code linked against
|
||||||
|
BoringSSL does not trigger this license.
|
||||||
|
|
||||||
|
Copyright 2015 The Chromium Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
1407
IoT-iOS/Pods/BoringSSL-GRPC/err_data.c
generated
Normal file
1407
IoT-iOS/Pods/BoringSSL-GRPC/err_data.c.grpc_back
generated
Normal file
271
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_bitstr.c
generated
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
|
||||||
|
{
|
||||||
|
return M_ASN1_BIT_STRING_set(x, d, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
int ret, j, bits, len;
|
||||||
|
unsigned char *p, *d;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
len = a->length;
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
if (a->flags & ASN1_STRING_FLAG_BITS_LEFT) {
|
||||||
|
bits = (int)a->flags & 0x07;
|
||||||
|
} else {
|
||||||
|
for (; len > 0; len--) {
|
||||||
|
if (a->data[len - 1])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
j = a->data[len - 1];
|
||||||
|
if (j & 0x01)
|
||||||
|
bits = 0;
|
||||||
|
else if (j & 0x02)
|
||||||
|
bits = 1;
|
||||||
|
else if (j & 0x04)
|
||||||
|
bits = 2;
|
||||||
|
else if (j & 0x08)
|
||||||
|
bits = 3;
|
||||||
|
else if (j & 0x10)
|
||||||
|
bits = 4;
|
||||||
|
else if (j & 0x20)
|
||||||
|
bits = 5;
|
||||||
|
else if (j & 0x40)
|
||||||
|
bits = 6;
|
||||||
|
else if (j & 0x80)
|
||||||
|
bits = 7;
|
||||||
|
else
|
||||||
|
bits = 0; /* should not happen */
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
bits = 0;
|
||||||
|
|
||||||
|
ret = 1 + len;
|
||||||
|
if (pp == NULL)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
|
||||||
|
*(p++) = (unsigned char)bits;
|
||||||
|
d = a->data;
|
||||||
|
OPENSSL_memcpy(p, d, len);
|
||||||
|
p += len;
|
||||||
|
if (len > 0)
|
||||||
|
p[-1] &= (0xff << bits);
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||||
|
const unsigned char **pp, long len)
|
||||||
|
{
|
||||||
|
ASN1_BIT_STRING *ret = NULL;
|
||||||
|
const unsigned char *p;
|
||||||
|
unsigned char *s;
|
||||||
|
int padding;
|
||||||
|
|
||||||
|
if (len < 1) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > INT_MAX) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((a == NULL) || ((*a) == NULL)) {
|
||||||
|
if ((ret = M_ASN1_BIT_STRING_new()) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
} else
|
||||||
|
ret = (*a);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
padding = *(p++);
|
||||||
|
if (padding > 7) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We do this to preserve the settings. If we modify the settings, via
|
||||||
|
* the _set_bit function, we will recalculate on output
|
||||||
|
*/
|
||||||
|
ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear */
|
||||||
|
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); /* set */
|
||||||
|
|
||||||
|
if (len-- > 1) { /* using one because of the bits left byte */
|
||||||
|
s = (unsigned char *)OPENSSL_malloc((int)len);
|
||||||
|
if (s == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
OPENSSL_memcpy(s, p, (int)len);
|
||||||
|
s[len - 1] &= (0xff << padding);
|
||||||
|
p += len;
|
||||||
|
} else
|
||||||
|
s = NULL;
|
||||||
|
|
||||||
|
ret->length = (int)len;
|
||||||
|
if (ret->data != NULL)
|
||||||
|
OPENSSL_free(ret->data);
|
||||||
|
ret->data = s;
|
||||||
|
ret->type = V_ASN1_BIT_STRING;
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||||
|
M_ASN1_BIT_STRING_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
|
||||||
|
*/
|
||||||
|
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
|
||||||
|
{
|
||||||
|
int w, v, iv;
|
||||||
|
unsigned char *c;
|
||||||
|
|
||||||
|
w = n / 8;
|
||||||
|
v = 1 << (7 - (n & 0x07));
|
||||||
|
iv = ~v;
|
||||||
|
if (!value)
|
||||||
|
v = 0;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
a->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear, set on write */
|
||||||
|
|
||||||
|
if ((a->length < (w + 1)) || (a->data == NULL)) {
|
||||||
|
if (!value)
|
||||||
|
return (1); /* Don't need to set */
|
||||||
|
if (a->data == NULL)
|
||||||
|
c = (unsigned char *)OPENSSL_malloc(w + 1);
|
||||||
|
else
|
||||||
|
c = (unsigned char *)OPENSSL_realloc(a->data, w + 1);
|
||||||
|
if (c == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (w + 1 - a->length > 0)
|
||||||
|
OPENSSL_memset(c + a->length, 0, w + 1 - a->length);
|
||||||
|
a->data = c;
|
||||||
|
a->length = w + 1;
|
||||||
|
}
|
||||||
|
a->data[w] = ((a->data[w]) & iv) | v;
|
||||||
|
while ((a->length > 0) && (a->data[a->length - 1] == 0))
|
||||||
|
a->length--;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
|
||||||
|
{
|
||||||
|
int w, v;
|
||||||
|
|
||||||
|
w = n / 8;
|
||||||
|
v = 1 << (7 - (n & 0x07));
|
||||||
|
if ((a == NULL) || (a->length < (w + 1)) || (a->data == NULL))
|
||||||
|
return (0);
|
||||||
|
return ((a->data[w] & v) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks if the given bit string contains only bits specified by
|
||||||
|
* the flags vector. Returns 0 if there is at least one bit set in 'a'
|
||||||
|
* which is not specified in 'flags', 1 otherwise.
|
||||||
|
* 'len' is the length of 'flags'.
|
||||||
|
*/
|
||||||
|
int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
|
||||||
|
unsigned char *flags, int flags_len)
|
||||||
|
{
|
||||||
|
int i, ok;
|
||||||
|
/* Check if there is one bit set at all. */
|
||||||
|
if (!a || !a->data)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check each byte of the internal representation of the bit string.
|
||||||
|
*/
|
||||||
|
ok = 1;
|
||||||
|
for (i = 0; i < a->length && ok; ++i) {
|
||||||
|
unsigned char mask = i < flags_len ? ~flags[i] : 0xff;
|
||||||
|
/* We are done if there is an unneeded bit set. */
|
||||||
|
ok = (a->data[i] & mask) == 0;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
271
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_bitstr.c.grpc_back
generated
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
|
||||||
|
{
|
||||||
|
return M_ASN1_BIT_STRING_set(x, d, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
int ret, j, bits, len;
|
||||||
|
unsigned char *p, *d;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
len = a->length;
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
if (a->flags & ASN1_STRING_FLAG_BITS_LEFT) {
|
||||||
|
bits = (int)a->flags & 0x07;
|
||||||
|
} else {
|
||||||
|
for (; len > 0; len--) {
|
||||||
|
if (a->data[len - 1])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
j = a->data[len - 1];
|
||||||
|
if (j & 0x01)
|
||||||
|
bits = 0;
|
||||||
|
else if (j & 0x02)
|
||||||
|
bits = 1;
|
||||||
|
else if (j & 0x04)
|
||||||
|
bits = 2;
|
||||||
|
else if (j & 0x08)
|
||||||
|
bits = 3;
|
||||||
|
else if (j & 0x10)
|
||||||
|
bits = 4;
|
||||||
|
else if (j & 0x20)
|
||||||
|
bits = 5;
|
||||||
|
else if (j & 0x40)
|
||||||
|
bits = 6;
|
||||||
|
else if (j & 0x80)
|
||||||
|
bits = 7;
|
||||||
|
else
|
||||||
|
bits = 0; /* should not happen */
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
bits = 0;
|
||||||
|
|
||||||
|
ret = 1 + len;
|
||||||
|
if (pp == NULL)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
|
||||||
|
*(p++) = (unsigned char)bits;
|
||||||
|
d = a->data;
|
||||||
|
OPENSSL_memcpy(p, d, len);
|
||||||
|
p += len;
|
||||||
|
if (len > 0)
|
||||||
|
p[-1] &= (0xff << bits);
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||||
|
const unsigned char **pp, long len)
|
||||||
|
{
|
||||||
|
ASN1_BIT_STRING *ret = NULL;
|
||||||
|
const unsigned char *p;
|
||||||
|
unsigned char *s;
|
||||||
|
int padding;
|
||||||
|
|
||||||
|
if (len < 1) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > INT_MAX) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((a == NULL) || ((*a) == NULL)) {
|
||||||
|
if ((ret = M_ASN1_BIT_STRING_new()) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
} else
|
||||||
|
ret = (*a);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
padding = *(p++);
|
||||||
|
if (padding > 7) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We do this to preserve the settings. If we modify the settings, via
|
||||||
|
* the _set_bit function, we will recalculate on output
|
||||||
|
*/
|
||||||
|
ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear */
|
||||||
|
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); /* set */
|
||||||
|
|
||||||
|
if (len-- > 1) { /* using one because of the bits left byte */
|
||||||
|
s = (unsigned char *)OPENSSL_malloc((int)len);
|
||||||
|
if (s == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
OPENSSL_memcpy(s, p, (int)len);
|
||||||
|
s[len - 1] &= (0xff << padding);
|
||||||
|
p += len;
|
||||||
|
} else
|
||||||
|
s = NULL;
|
||||||
|
|
||||||
|
ret->length = (int)len;
|
||||||
|
if (ret->data != NULL)
|
||||||
|
OPENSSL_free(ret->data);
|
||||||
|
ret->data = s;
|
||||||
|
ret->type = V_ASN1_BIT_STRING;
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||||
|
M_ASN1_BIT_STRING_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
|
||||||
|
*/
|
||||||
|
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
|
||||||
|
{
|
||||||
|
int w, v, iv;
|
||||||
|
unsigned char *c;
|
||||||
|
|
||||||
|
w = n / 8;
|
||||||
|
v = 1 << (7 - (n & 0x07));
|
||||||
|
iv = ~v;
|
||||||
|
if (!value)
|
||||||
|
v = 0;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
a->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear, set on write */
|
||||||
|
|
||||||
|
if ((a->length < (w + 1)) || (a->data == NULL)) {
|
||||||
|
if (!value)
|
||||||
|
return (1); /* Don't need to set */
|
||||||
|
if (a->data == NULL)
|
||||||
|
c = (unsigned char *)OPENSSL_malloc(w + 1);
|
||||||
|
else
|
||||||
|
c = (unsigned char *)OPENSSL_realloc(a->data, w + 1);
|
||||||
|
if (c == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (w + 1 - a->length > 0)
|
||||||
|
OPENSSL_memset(c + a->length, 0, w + 1 - a->length);
|
||||||
|
a->data = c;
|
||||||
|
a->length = w + 1;
|
||||||
|
}
|
||||||
|
a->data[w] = ((a->data[w]) & iv) | v;
|
||||||
|
while ((a->length > 0) && (a->data[a->length - 1] == 0))
|
||||||
|
a->length--;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
|
||||||
|
{
|
||||||
|
int w, v;
|
||||||
|
|
||||||
|
w = n / 8;
|
||||||
|
v = 1 << (7 - (n & 0x07));
|
||||||
|
if ((a == NULL) || (a->length < (w + 1)) || (a->data == NULL))
|
||||||
|
return (0);
|
||||||
|
return ((a->data[w] & v) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks if the given bit string contains only bits specified by
|
||||||
|
* the flags vector. Returns 0 if there is at least one bit set in 'a'
|
||||||
|
* which is not specified in 'flags', 1 otherwise.
|
||||||
|
* 'len' is the length of 'flags'.
|
||||||
|
*/
|
||||||
|
int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
|
||||||
|
unsigned char *flags, int flags_len)
|
||||||
|
{
|
||||||
|
int i, ok;
|
||||||
|
/* Check if there is one bit set at all. */
|
||||||
|
if (!a || !a->data)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check each byte of the internal representation of the bit string.
|
||||||
|
*/
|
||||||
|
ok = 1;
|
||||||
|
for (i = 0; i < a->length && ok; ++i) {
|
||||||
|
unsigned char mask = i < flags_len ? ~flags[i] : 0xff;
|
||||||
|
/* We are done if there is an unneeded bit set. */
|
||||||
|
ok = (a->data[i] & mask) == 0;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
123
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_bool.c
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
int i2d_ASN1_BOOLEAN(int a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
unsigned char *p, *allocated = NULL;
|
||||||
|
|
||||||
|
r = ASN1_object_size(0, 1, V_ASN1_BOOLEAN);
|
||||||
|
if (pp == NULL)
|
||||||
|
return (r);
|
||||||
|
|
||||||
|
if (*pp == NULL) {
|
||||||
|
if ((p = allocated = OPENSSL_malloc(r)) == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p = *pp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_put_object(&p, 0, 1, V_ASN1_BOOLEAN, V_ASN1_UNIVERSAL);
|
||||||
|
*p = (unsigned char)a;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If a new buffer was allocated, just return it back.
|
||||||
|
* If not, return the incremented buffer pointer.
|
||||||
|
*/
|
||||||
|
*pp = allocated != NULL ? allocated : p + 1;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
const unsigned char *p;
|
||||||
|
long len;
|
||||||
|
int inf, tag, xclass;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
inf = ASN1_get_object(&p, &len, &tag, &xclass, length);
|
||||||
|
if (inf & 0x80) {
|
||||||
|
i = ASN1_R_BAD_OBJECT_HEADER;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag != V_ASN1_BOOLEAN) {
|
||||||
|
i = ASN1_R_EXPECTING_A_BOOLEAN;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len != 1) {
|
||||||
|
i = ASN1_R_BOOLEAN_IS_WRONG_LENGTH;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret = (int)*(p++);
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
123
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_bool.c.grpc_back
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
int i2d_ASN1_BOOLEAN(int a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
unsigned char *p, *allocated = NULL;
|
||||||
|
|
||||||
|
r = ASN1_object_size(0, 1, V_ASN1_BOOLEAN);
|
||||||
|
if (pp == NULL)
|
||||||
|
return (r);
|
||||||
|
|
||||||
|
if (*pp == NULL) {
|
||||||
|
if ((p = allocated = OPENSSL_malloc(r)) == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p = *pp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_put_object(&p, 0, 1, V_ASN1_BOOLEAN, V_ASN1_UNIVERSAL);
|
||||||
|
*p = (unsigned char)a;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If a new buffer was allocated, just return it back.
|
||||||
|
* If not, return the incremented buffer pointer.
|
||||||
|
*/
|
||||||
|
*pp = allocated != NULL ? allocated : p + 1;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
const unsigned char *p;
|
||||||
|
long len;
|
||||||
|
int inf, tag, xclass;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
inf = ASN1_get_object(&p, &len, &tag, &xclass, length);
|
||||||
|
if (inf & 0x80) {
|
||||||
|
i = ASN1_R_BAD_OBJECT_HEADER;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag != V_ASN1_BOOLEAN) {
|
||||||
|
i = ASN1_R_EXPECTING_A_BOOLEAN;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len != 1) {
|
||||||
|
i = ASN1_R_BOOLEAN_IS_WRONG_LENGTH;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret = (int)*(p++);
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
93
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_d2i_fp.c
generated
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/bio.h>
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
|
||||||
|
void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
|
||||||
|
{
|
||||||
|
uint8_t *data;
|
||||||
|
size_t len;
|
||||||
|
// Historically, this function did not impose a limit in OpenSSL and is used
|
||||||
|
// to read CRLs, so we leave this without an external bound.
|
||||||
|
if (!BIO_read_asn1(in, &data, &len, INT_MAX)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
const uint8_t *ptr = data;
|
||||||
|
void *ret = ASN1_item_d2i(x, &ptr, len, it);
|
||||||
|
OPENSSL_free(data);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_FP_API
|
||||||
|
void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
|
||||||
|
{
|
||||||
|
BIO *b = BIO_new_fp(in, BIO_NOCLOSE);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
void *ret = ASN1_item_d2i_bio(it, b, x);
|
||||||
|
BIO_free(b);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
93
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_d2i_fp.c.grpc_back
generated
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <openssl/bio.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
|
||||||
|
void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
|
||||||
|
{
|
||||||
|
uint8_t *data;
|
||||||
|
size_t len;
|
||||||
|
// Historically, this function did not impose a limit in OpenSSL and is used
|
||||||
|
// to read CRLs, so we leave this without an external bound.
|
||||||
|
if (!BIO_read_asn1(in, &data, &len, INT_MAX)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
const uint8_t *ptr = data;
|
||||||
|
void *ret = ASN1_item_d2i(x, &ptr, len, it);
|
||||||
|
OPENSSL_free(data);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_FP_API
|
||||||
|
void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
|
||||||
|
{
|
||||||
|
BIO *b = BIO_new_fp(in, BIO_NOCLOSE);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
void *ret = ASN1_item_d2i_bio(it, b, x);
|
||||||
|
BIO_free(b);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
87
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_dup.c
generated
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASN1_ITEM version of dup: this follows the model above except we don't
|
||||||
|
* need to allocate the buffer. At some point this could be rewritten to
|
||||||
|
* directly dup the underlying structure instead of doing and encode and
|
||||||
|
* decode.
|
||||||
|
*/
|
||||||
|
void *ASN1_item_dup(const ASN1_ITEM *it, void *x)
|
||||||
|
{
|
||||||
|
unsigned char *b = NULL;
|
||||||
|
const unsigned char *p;
|
||||||
|
long i;
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
if (x == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
i = ASN1_item_i2d(x, &b, it);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
p = b;
|
||||||
|
ret = ASN1_item_d2i(NULL, &p, i, it);
|
||||||
|
OPENSSL_free(b);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
87
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_dup.c.grpc_back
generated
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASN1_ITEM version of dup: this follows the model above except we don't
|
||||||
|
* need to allocate the buffer. At some point this could be rewritten to
|
||||||
|
* directly dup the underlying structure instead of doing and encode and
|
||||||
|
* decode.
|
||||||
|
*/
|
||||||
|
void *ASN1_item_dup(const ASN1_ITEM *it, void *x)
|
||||||
|
{
|
||||||
|
unsigned char *b = NULL;
|
||||||
|
const unsigned char *p;
|
||||||
|
long i;
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
if (x == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
i = ASN1_item_i2d(x, &b, it);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
p = b;
|
||||||
|
ret = ASN1_item_d2i(NULL, &p, i, it);
|
||||||
|
OPENSSL_free(b);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
195
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_enum.c
generated
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Code for ENUMERATED type: identical to INTEGER apart from a different tag.
|
||||||
|
* for comments on encoding see a_int.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
|
||||||
|
{
|
||||||
|
int j, k;
|
||||||
|
unsigned int i;
|
||||||
|
unsigned char buf[sizeof(long) + 1];
|
||||||
|
long d;
|
||||||
|
|
||||||
|
a->type = V_ASN1_ENUMERATED;
|
||||||
|
if (a->length < (int)(sizeof(long) + 1)) {
|
||||||
|
if (a->data != NULL)
|
||||||
|
OPENSSL_free(a->data);
|
||||||
|
if ((a->data =
|
||||||
|
(unsigned char *)OPENSSL_malloc(sizeof(long) + 1)) != NULL)
|
||||||
|
OPENSSL_memset((char *)a->data, 0, sizeof(long) + 1);
|
||||||
|
}
|
||||||
|
if (a->data == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
d = v;
|
||||||
|
if (d < 0) {
|
||||||
|
d = -d;
|
||||||
|
a->type = V_ASN1_NEG_ENUMERATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(long); i++) {
|
||||||
|
if (d == 0)
|
||||||
|
break;
|
||||||
|
buf[i] = (int)d & 0xff;
|
||||||
|
d >>= 8;
|
||||||
|
}
|
||||||
|
j = 0;
|
||||||
|
for (k = i - 1; k >= 0; k--)
|
||||||
|
a->data[j++] = buf[k];
|
||||||
|
a->length = j;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
|
||||||
|
{
|
||||||
|
int neg = 0, i;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0L);
|
||||||
|
i = a->type;
|
||||||
|
if (i == V_ASN1_NEG_ENUMERATED)
|
||||||
|
neg = 1;
|
||||||
|
else if (i != V_ASN1_ENUMERATED)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
|
||||||
|
"long larger than uint64_t");
|
||||||
|
|
||||||
|
if (a->length > (int)sizeof(uint64_t)) {
|
||||||
|
/* hmm... a bit ugly */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t r64 = 0;
|
||||||
|
if (a->data != NULL) {
|
||||||
|
for (i = 0; i < a->length; i++) {
|
||||||
|
r64 <<= 8;
|
||||||
|
r64 |= (unsigned char)a->data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r64 > LONG_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long r = (long) r64;
|
||||||
|
if (neg)
|
||||||
|
r = -r;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
|
||||||
|
{
|
||||||
|
ASN1_ENUMERATED *ret;
|
||||||
|
int len, j;
|
||||||
|
|
||||||
|
if (ai == NULL)
|
||||||
|
ret = M_ASN1_ENUMERATED_new();
|
||||||
|
else
|
||||||
|
ret = ai;
|
||||||
|
if (ret == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (BN_is_negative(bn))
|
||||||
|
ret->type = V_ASN1_NEG_ENUMERATED;
|
||||||
|
else
|
||||||
|
ret->type = V_ASN1_ENUMERATED;
|
||||||
|
j = BN_num_bits(bn);
|
||||||
|
len = ((j == 0) ? 0 : ((j / 8) + 1));
|
||||||
|
if (ret->length < len + 4) {
|
||||||
|
unsigned char *new_data = OPENSSL_realloc(ret->data, len + 4);
|
||||||
|
if (!new_data) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret->data = new_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret->length = BN_bn2bin(bn, ret->data);
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
if (ret != ai)
|
||||||
|
M_ASN1_ENUMERATED_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn)
|
||||||
|
{
|
||||||
|
BIGNUM *ret;
|
||||||
|
|
||||||
|
if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL)
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BN_LIB);
|
||||||
|
else if (ai->type == V_ASN1_NEG_ENUMERATED)
|
||||||
|
BN_set_negative(ret, 1);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
195
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_enum.c.grpc_back
generated
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Code for ENUMERATED type: identical to INTEGER apart from a different tag.
|
||||||
|
* for comments on encoding see a_int.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
|
||||||
|
{
|
||||||
|
int j, k;
|
||||||
|
unsigned int i;
|
||||||
|
unsigned char buf[sizeof(long) + 1];
|
||||||
|
long d;
|
||||||
|
|
||||||
|
a->type = V_ASN1_ENUMERATED;
|
||||||
|
if (a->length < (int)(sizeof(long) + 1)) {
|
||||||
|
if (a->data != NULL)
|
||||||
|
OPENSSL_free(a->data);
|
||||||
|
if ((a->data =
|
||||||
|
(unsigned char *)OPENSSL_malloc(sizeof(long) + 1)) != NULL)
|
||||||
|
OPENSSL_memset((char *)a->data, 0, sizeof(long) + 1);
|
||||||
|
}
|
||||||
|
if (a->data == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
d = v;
|
||||||
|
if (d < 0) {
|
||||||
|
d = -d;
|
||||||
|
a->type = V_ASN1_NEG_ENUMERATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(long); i++) {
|
||||||
|
if (d == 0)
|
||||||
|
break;
|
||||||
|
buf[i] = (int)d & 0xff;
|
||||||
|
d >>= 8;
|
||||||
|
}
|
||||||
|
j = 0;
|
||||||
|
for (k = i - 1; k >= 0; k--)
|
||||||
|
a->data[j++] = buf[k];
|
||||||
|
a->length = j;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
|
||||||
|
{
|
||||||
|
int neg = 0, i;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0L);
|
||||||
|
i = a->type;
|
||||||
|
if (i == V_ASN1_NEG_ENUMERATED)
|
||||||
|
neg = 1;
|
||||||
|
else if (i != V_ASN1_ENUMERATED)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
|
||||||
|
"long larger than uint64_t");
|
||||||
|
|
||||||
|
if (a->length > (int)sizeof(uint64_t)) {
|
||||||
|
/* hmm... a bit ugly */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t r64 = 0;
|
||||||
|
if (a->data != NULL) {
|
||||||
|
for (i = 0; i < a->length; i++) {
|
||||||
|
r64 <<= 8;
|
||||||
|
r64 |= (unsigned char)a->data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r64 > LONG_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long r = (long) r64;
|
||||||
|
if (neg)
|
||||||
|
r = -r;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
|
||||||
|
{
|
||||||
|
ASN1_ENUMERATED *ret;
|
||||||
|
int len, j;
|
||||||
|
|
||||||
|
if (ai == NULL)
|
||||||
|
ret = M_ASN1_ENUMERATED_new();
|
||||||
|
else
|
||||||
|
ret = ai;
|
||||||
|
if (ret == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (BN_is_negative(bn))
|
||||||
|
ret->type = V_ASN1_NEG_ENUMERATED;
|
||||||
|
else
|
||||||
|
ret->type = V_ASN1_ENUMERATED;
|
||||||
|
j = BN_num_bits(bn);
|
||||||
|
len = ((j == 0) ? 0 : ((j / 8) + 1));
|
||||||
|
if (ret->length < len + 4) {
|
||||||
|
unsigned char *new_data = OPENSSL_realloc(ret->data, len + 4);
|
||||||
|
if (!new_data) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret->data = new_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret->length = BN_bn2bin(bn, ret->data);
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
if (ret != ai)
|
||||||
|
M_ASN1_ENUMERATED_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn)
|
||||||
|
{
|
||||||
|
BIGNUM *ret;
|
||||||
|
|
||||||
|
if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL)
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BN_LIB);
|
||||||
|
else if (ai->type == V_ASN1_NEG_ENUMERATED)
|
||||||
|
BN_set_negative(ret, 1);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
261
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_gentm.c
generated
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
|
||||||
|
{
|
||||||
|
static const int min[9] = { 0, 0, 1, 1, 0, 0, 0, 0, 0 };
|
||||||
|
static const int max[9] = { 99, 99, 12, 31, 23, 59, 59, 12, 59 };
|
||||||
|
char *a;
|
||||||
|
int n, i, l, o;
|
||||||
|
|
||||||
|
if (d->type != V_ASN1_GENERALIZEDTIME)
|
||||||
|
return (0);
|
||||||
|
l = d->length;
|
||||||
|
a = (char *)d->data;
|
||||||
|
o = 0;
|
||||||
|
/*
|
||||||
|
* GENERALIZEDTIME is similar to UTCTIME except the year is represented
|
||||||
|
* as YYYY. This stuff treats everything as a two digit field so make
|
||||||
|
* first two fields 00 to 99
|
||||||
|
*/
|
||||||
|
if (l < 13)
|
||||||
|
goto err;
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
if ((i == 6) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||||
|
i++;
|
||||||
|
if (tm)
|
||||||
|
tm->tm_sec = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
tm->tm_year = n * 100 - 1900;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
tm->tm_year += n;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
tm->tm_mon = n - 1;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
tm->tm_mday = n;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
tm->tm_hour = n;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
tm->tm_min = n;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
tm->tm_sec = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Optional fractional seconds: decimal point followed by one or more
|
||||||
|
* digits.
|
||||||
|
*/
|
||||||
|
if (a[o] == '.') {
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
i = o;
|
||||||
|
while ((a[o] >= '0') && (a[o] <= '9') && (o <= l))
|
||||||
|
o++;
|
||||||
|
/* Must have at least one digit after decimal point */
|
||||||
|
if (i == o)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a[o] == 'Z')
|
||||||
|
o++;
|
||||||
|
else if ((a[o] == '+') || (a[o] == '-')) {
|
||||||
|
int offsign = a[o] == '-' ? 1 : -1, offset = 0;
|
||||||
|
o++;
|
||||||
|
if (o + 4 > l)
|
||||||
|
goto err;
|
||||||
|
for (i = 7; i < 9; i++) {
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
o++;
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
if (i == 7)
|
||||||
|
offset = n * 3600;
|
||||||
|
else if (i == 8)
|
||||||
|
offset += n * 60;
|
||||||
|
}
|
||||||
|
o++;
|
||||||
|
}
|
||||||
|
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||||
|
return 0;
|
||||||
|
} else if (a[o]) {
|
||||||
|
/* Missing time zone information. */
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
return (o == l);
|
||||||
|
err:
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d)
|
||||||
|
{
|
||||||
|
return asn1_generalizedtime_to_tm(NULL, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
|
||||||
|
{
|
||||||
|
ASN1_GENERALIZEDTIME t;
|
||||||
|
|
||||||
|
t.type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
t.length = strlen(str);
|
||||||
|
t.data = (unsigned char *)str;
|
||||||
|
if (ASN1_GENERALIZEDTIME_check(&t)) {
|
||||||
|
if (s != NULL) {
|
||||||
|
if (!ASN1_STRING_set((ASN1_STRING *)s,
|
||||||
|
(unsigned char *)str, t.length))
|
||||||
|
return 0;
|
||||||
|
s->type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
} else
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
|
||||||
|
time_t t)
|
||||||
|
{
|
||||||
|
return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
|
||||||
|
time_t t, int offset_day,
|
||||||
|
long offset_sec)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
struct tm *ts;
|
||||||
|
struct tm data;
|
||||||
|
size_t len = 20;
|
||||||
|
ASN1_GENERALIZEDTIME *tmps = NULL;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
tmps = ASN1_GENERALIZEDTIME_new();
|
||||||
|
else
|
||||||
|
tmps = s;
|
||||||
|
if (tmps == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ts = OPENSSL_gmtime(&t, &data);
|
||||||
|
if (ts == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (offset_day || offset_sec) {
|
||||||
|
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = (char *)tmps->data;
|
||||||
|
if ((p == NULL) || ((size_t)tmps->length < len)) {
|
||||||
|
p = OPENSSL_malloc(len);
|
||||||
|
if (p == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
OPENSSL_free(tmps->data);
|
||||||
|
tmps->data = (unsigned char *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900,
|
||||||
|
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||||
|
ts->tm_sec);
|
||||||
|
tmps->length = strlen(p);
|
||||||
|
tmps->type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
return tmps;
|
||||||
|
err:
|
||||||
|
if (s == NULL)
|
||||||
|
ASN1_GENERALIZEDTIME_free(tmps);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
261
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_gentm.c.grpc_back
generated
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
|
||||||
|
{
|
||||||
|
static const int min[9] = { 0, 0, 1, 1, 0, 0, 0, 0, 0 };
|
||||||
|
static const int max[9] = { 99, 99, 12, 31, 23, 59, 59, 12, 59 };
|
||||||
|
char *a;
|
||||||
|
int n, i, l, o;
|
||||||
|
|
||||||
|
if (d->type != V_ASN1_GENERALIZEDTIME)
|
||||||
|
return (0);
|
||||||
|
l = d->length;
|
||||||
|
a = (char *)d->data;
|
||||||
|
o = 0;
|
||||||
|
/*
|
||||||
|
* GENERALIZEDTIME is similar to UTCTIME except the year is represented
|
||||||
|
* as YYYY. This stuff treats everything as a two digit field so make
|
||||||
|
* first two fields 00 to 99
|
||||||
|
*/
|
||||||
|
if (l < 13)
|
||||||
|
goto err;
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
if ((i == 6) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||||
|
i++;
|
||||||
|
if (tm)
|
||||||
|
tm->tm_sec = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
tm->tm_year = n * 100 - 1900;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
tm->tm_year += n;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
tm->tm_mon = n - 1;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
tm->tm_mday = n;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
tm->tm_hour = n;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
tm->tm_min = n;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
tm->tm_sec = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Optional fractional seconds: decimal point followed by one or more
|
||||||
|
* digits.
|
||||||
|
*/
|
||||||
|
if (a[o] == '.') {
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
i = o;
|
||||||
|
while ((a[o] >= '0') && (a[o] <= '9') && (o <= l))
|
||||||
|
o++;
|
||||||
|
/* Must have at least one digit after decimal point */
|
||||||
|
if (i == o)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a[o] == 'Z')
|
||||||
|
o++;
|
||||||
|
else if ((a[o] == '+') || (a[o] == '-')) {
|
||||||
|
int offsign = a[o] == '-' ? 1 : -1, offset = 0;
|
||||||
|
o++;
|
||||||
|
if (o + 4 > l)
|
||||||
|
goto err;
|
||||||
|
for (i = 7; i < 9; i++) {
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
o++;
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
if (i == 7)
|
||||||
|
offset = n * 3600;
|
||||||
|
else if (i == 8)
|
||||||
|
offset += n * 60;
|
||||||
|
}
|
||||||
|
o++;
|
||||||
|
}
|
||||||
|
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||||
|
return 0;
|
||||||
|
} else if (a[o]) {
|
||||||
|
/* Missing time zone information. */
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
return (o == l);
|
||||||
|
err:
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d)
|
||||||
|
{
|
||||||
|
return asn1_generalizedtime_to_tm(NULL, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
|
||||||
|
{
|
||||||
|
ASN1_GENERALIZEDTIME t;
|
||||||
|
|
||||||
|
t.type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
t.length = strlen(str);
|
||||||
|
t.data = (unsigned char *)str;
|
||||||
|
if (ASN1_GENERALIZEDTIME_check(&t)) {
|
||||||
|
if (s != NULL) {
|
||||||
|
if (!ASN1_STRING_set((ASN1_STRING *)s,
|
||||||
|
(unsigned char *)str, t.length))
|
||||||
|
return 0;
|
||||||
|
s->type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
} else
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
|
||||||
|
time_t t)
|
||||||
|
{
|
||||||
|
return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
|
||||||
|
time_t t, int offset_day,
|
||||||
|
long offset_sec)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
struct tm *ts;
|
||||||
|
struct tm data;
|
||||||
|
size_t len = 20;
|
||||||
|
ASN1_GENERALIZEDTIME *tmps = NULL;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
tmps = ASN1_GENERALIZEDTIME_new();
|
||||||
|
else
|
||||||
|
tmps = s;
|
||||||
|
if (tmps == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ts = OPENSSL_gmtime(&t, &data);
|
||||||
|
if (ts == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (offset_day || offset_sec) {
|
||||||
|
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = (char *)tmps->data;
|
||||||
|
if ((p == NULL) || ((size_t)tmps->length < len)) {
|
||||||
|
p = OPENSSL_malloc(len);
|
||||||
|
if (p == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
OPENSSL_free(tmps->data);
|
||||||
|
tmps->data = (unsigned char *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900,
|
||||||
|
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||||
|
ts->tm_sec);
|
||||||
|
tmps->length = strlen(p);
|
||||||
|
tmps->type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
return tmps;
|
||||||
|
err:
|
||||||
|
if (s == NULL)
|
||||||
|
ASN1_GENERALIZEDTIME_free(tmps);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
88
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_i2d_fp.c
generated
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/bio.h>
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
|
||||||
|
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
|
||||||
|
{
|
||||||
|
BIO *b = BIO_new_fp(out, BIO_NOCLOSE);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int ret = ASN1_item_i2d_bio(it, b, x);
|
||||||
|
BIO_free(b);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
|
||||||
|
{
|
||||||
|
unsigned char *b = NULL;
|
||||||
|
int n = ASN1_item_i2d(x, &b, it);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = BIO_write_all(out, b, n);
|
||||||
|
OPENSSL_free(b);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
88
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_i2d_fp.c.grpc_back
generated
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl/bio.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
|
||||||
|
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
|
||||||
|
{
|
||||||
|
BIO *b = BIO_new_fp(out, BIO_NOCLOSE);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int ret = ASN1_item_i2d_bio(it, b, x);
|
||||||
|
BIO_free(b);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
|
||||||
|
{
|
||||||
|
unsigned char *b = NULL;
|
||||||
|
int n = ASN1_item_i2d(x, &b, it);
|
||||||
|
if (b == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = BIO_write_all(out, b, n);
|
||||||
|
OPENSSL_free(b);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
420
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_int.c
generated
Normal file
@ -0,0 +1,420 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x)
|
||||||
|
{
|
||||||
|
return M_ASN1_INTEGER_dup(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y)
|
||||||
|
{
|
||||||
|
int neg, ret;
|
||||||
|
/* Compare signs */
|
||||||
|
neg = x->type & V_ASN1_NEG;
|
||||||
|
if (neg != (y->type & V_ASN1_NEG)) {
|
||||||
|
if (neg)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ASN1_STRING_cmp(x, y);
|
||||||
|
|
||||||
|
if (neg)
|
||||||
|
return -ret;
|
||||||
|
else
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This converts an ASN1 INTEGER into its content encoding.
|
||||||
|
* The internal representation is an ASN1_STRING whose data is a big endian
|
||||||
|
* representation of the value, ignoring the sign. The sign is determined by
|
||||||
|
* the type: V_ASN1_INTEGER for positive and V_ASN1_NEG_INTEGER for negative.
|
||||||
|
*
|
||||||
|
* Positive integers are no problem: they are almost the same as the DER
|
||||||
|
* encoding, except if the first byte is >= 0x80 we need to add a zero pad.
|
||||||
|
*
|
||||||
|
* Negative integers are a bit trickier...
|
||||||
|
* The DER representation of negative integers is in 2s complement form.
|
||||||
|
* The internal form is converted by complementing each octet and finally
|
||||||
|
* adding one to the result. This can be done less messily with a little trick.
|
||||||
|
* If the internal form has trailing zeroes then they will become FF by the
|
||||||
|
* complement and 0 by the add one (due to carry) so just copy as many trailing
|
||||||
|
* zeros to the destination as there are in the source. The carry will add one
|
||||||
|
* to the last none zero octet: so complement this octet and add one and finally
|
||||||
|
* complement any left over until you get to the start of the string.
|
||||||
|
*
|
||||||
|
* Padding is a little trickier too. If the first bytes is > 0x80 then we pad
|
||||||
|
* with 0xff. However if the first byte is 0x80 and one of the following bytes
|
||||||
|
* is non-zero we pad with 0xff. The reason for this distinction is that 0x80
|
||||||
|
* followed by optional zeros isn't padded.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
int pad = 0, ret, i, neg;
|
||||||
|
unsigned char *p, *n, pb = 0;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0);
|
||||||
|
neg = a->type & V_ASN1_NEG;
|
||||||
|
if (a->length == 0)
|
||||||
|
ret = 1;
|
||||||
|
else {
|
||||||
|
ret = a->length;
|
||||||
|
i = a->data[0];
|
||||||
|
if (ret == 1 && i == 0)
|
||||||
|
neg = 0;
|
||||||
|
if (!neg && (i > 127)) {
|
||||||
|
pad = 1;
|
||||||
|
pb = 0;
|
||||||
|
} else if (neg) {
|
||||||
|
if (i > 128) {
|
||||||
|
pad = 1;
|
||||||
|
pb = 0xFF;
|
||||||
|
} else if (i == 128) {
|
||||||
|
/*
|
||||||
|
* Special case: if any other bytes non zero we pad:
|
||||||
|
* otherwise we don't.
|
||||||
|
*/
|
||||||
|
for (i = 1; i < a->length; i++)
|
||||||
|
if (a->data[i]) {
|
||||||
|
pad = 1;
|
||||||
|
pb = 0xFF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret += pad;
|
||||||
|
}
|
||||||
|
if (pp == NULL)
|
||||||
|
return (ret);
|
||||||
|
p = *pp;
|
||||||
|
|
||||||
|
if (pad)
|
||||||
|
*(p++) = pb;
|
||||||
|
if (a->length == 0)
|
||||||
|
*(p++) = 0;
|
||||||
|
else if (!neg)
|
||||||
|
OPENSSL_memcpy(p, a->data, (unsigned int)a->length);
|
||||||
|
else {
|
||||||
|
/* Begin at the end of the encoding */
|
||||||
|
n = a->data + a->length - 1;
|
||||||
|
p += a->length - 1;
|
||||||
|
i = a->length;
|
||||||
|
/* Copy zeros to destination as long as source is zero */
|
||||||
|
while (!*n && i > 1) {
|
||||||
|
*(p--) = 0;
|
||||||
|
n--;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
/* Complement and increment next octet */
|
||||||
|
*(p--) = ((*(n--)) ^ 0xff) + 1;
|
||||||
|
i--;
|
||||||
|
/* Complement any octets left */
|
||||||
|
for (; i > 0; i--)
|
||||||
|
*(p--) = *(n--) ^ 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pp += ret;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
|
||||||
|
|
||||||
|
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
|
||||||
|
long len)
|
||||||
|
{
|
||||||
|
ASN1_INTEGER *ret = NULL;
|
||||||
|
const unsigned char *p, *pend;
|
||||||
|
unsigned char *to, *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function can handle lengths up to INT_MAX - 1, but the rest of the
|
||||||
|
* legacy ASN.1 code mixes integer types, so avoid exposing it to
|
||||||
|
* ASN1_INTEGERS with larger lengths.
|
||||||
|
*/
|
||||||
|
if (len < 0 || len > INT_MAX / 2) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((a == NULL) || ((*a) == NULL)) {
|
||||||
|
if ((ret = M_ASN1_INTEGER_new()) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
} else
|
||||||
|
ret = (*a);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
pend = p + len;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it signifies
|
||||||
|
* a missing NULL parameter.
|
||||||
|
*/
|
||||||
|
s = (unsigned char *)OPENSSL_malloc((int)len + 1);
|
||||||
|
if (s == NULL) {
|
||||||
|
i = ERR_R_MALLOC_FAILURE;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
to = s;
|
||||||
|
if (!len) {
|
||||||
|
/*
|
||||||
|
* Strictly speaking this is an illegal INTEGER but we tolerate it.
|
||||||
|
*/
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
} else if (*p & 0x80) { /* a negative number */
|
||||||
|
ret->type = V_ASN1_NEG_INTEGER;
|
||||||
|
if ((*p == 0xff) && (len != 1)) {
|
||||||
|
p++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
i = len;
|
||||||
|
p += i - 1;
|
||||||
|
to += i - 1;
|
||||||
|
while ((!*p) && i) {
|
||||||
|
*(to--) = 0;
|
||||||
|
i--;
|
||||||
|
p--;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Special case: if all zeros then the number will be of the form FF
|
||||||
|
* followed by n zero bytes: this corresponds to 1 followed by n zero
|
||||||
|
* bytes. We've already written n zeros so we just append an extra
|
||||||
|
* one and set the first byte to a 1. This is treated separately
|
||||||
|
* because it is the only case where the number of bytes is larger
|
||||||
|
* than len.
|
||||||
|
*/
|
||||||
|
if (!i) {
|
||||||
|
*s = 1;
|
||||||
|
s[len] = 0;
|
||||||
|
len++;
|
||||||
|
} else {
|
||||||
|
*(to--) = (*(p--) ^ 0xff) + 1;
|
||||||
|
i--;
|
||||||
|
for (; i > 0; i--)
|
||||||
|
*(to--) = *(p--) ^ 0xff;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
if ((*p == 0) && (len != 1)) {
|
||||||
|
p++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
OPENSSL_memcpy(s, p, (int)len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret->data != NULL)
|
||||||
|
OPENSSL_free(ret->data);
|
||||||
|
ret->data = s;
|
||||||
|
ret->length = (int)len;
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = pend;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||||
|
M_ASN1_INTEGER_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
|
||||||
|
{
|
||||||
|
if (v >= 0) {
|
||||||
|
return ASN1_INTEGER_set_uint64(a, (uint64_t) v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ASN1_INTEGER_set_uint64(a, 0 - (uint64_t) v)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a->type = V_ASN1_NEG_INTEGER;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_INTEGER_set_uint64(ASN1_INTEGER *out, uint64_t v)
|
||||||
|
{
|
||||||
|
uint8_t *const newdata = OPENSSL_malloc(sizeof(uint64_t));
|
||||||
|
if (newdata == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENSSL_free(out->data);
|
||||||
|
out->data = newdata;
|
||||||
|
v = CRYPTO_bswap8(v);
|
||||||
|
memcpy(out->data, &v, sizeof(v));
|
||||||
|
|
||||||
|
out->type = V_ASN1_INTEGER;
|
||||||
|
|
||||||
|
size_t leading_zeros;
|
||||||
|
for (leading_zeros = 0; leading_zeros < sizeof(uint64_t) - 1;
|
||||||
|
leading_zeros++) {
|
||||||
|
if (out->data[leading_zeros] != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out->length = sizeof(uint64_t) - leading_zeros;
|
||||||
|
OPENSSL_memmove(out->data, out->data + leading_zeros, out->length);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
long ASN1_INTEGER_get(const ASN1_INTEGER *a)
|
||||||
|
{
|
||||||
|
int neg = 0, i;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0L);
|
||||||
|
i = a->type;
|
||||||
|
if (i == V_ASN1_NEG_INTEGER)
|
||||||
|
neg = 1;
|
||||||
|
else if (i != V_ASN1_INTEGER)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
|
||||||
|
"long larger than uint64_t");
|
||||||
|
|
||||||
|
if (a->length > (int)sizeof(uint64_t)) {
|
||||||
|
/* hmm... a bit ugly, return all ones */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t r64 = 0;
|
||||||
|
if (a->data != NULL) {
|
||||||
|
for (i = 0; i < a->length; i++) {
|
||||||
|
r64 <<= 8;
|
||||||
|
r64 |= (unsigned char)a->data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r64 > LONG_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long r = (long) r64;
|
||||||
|
if (neg)
|
||||||
|
r = -r;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
|
||||||
|
{
|
||||||
|
ASN1_INTEGER *ret;
|
||||||
|
int len, j;
|
||||||
|
|
||||||
|
if (ai == NULL)
|
||||||
|
ret = M_ASN1_INTEGER_new();
|
||||||
|
else
|
||||||
|
ret = ai;
|
||||||
|
if (ret == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (BN_is_negative(bn) && !BN_is_zero(bn))
|
||||||
|
ret->type = V_ASN1_NEG_INTEGER;
|
||||||
|
else
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
j = BN_num_bits(bn);
|
||||||
|
len = ((j == 0) ? 0 : ((j / 8) + 1));
|
||||||
|
if (ret->length < len + 4) {
|
||||||
|
unsigned char *new_data = OPENSSL_realloc(ret->data, len + 4);
|
||||||
|
if (!new_data) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret->data = new_data;
|
||||||
|
}
|
||||||
|
ret->length = BN_bn2bin(bn, ret->data);
|
||||||
|
/* Correct zero case */
|
||||||
|
if (!ret->length) {
|
||||||
|
ret->data[0] = 0;
|
||||||
|
ret->length = 1;
|
||||||
|
}
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
if (ret != ai)
|
||||||
|
M_ASN1_INTEGER_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
|
||||||
|
{
|
||||||
|
BIGNUM *ret;
|
||||||
|
|
||||||
|
if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL)
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BN_LIB);
|
||||||
|
else if (ai->type == V_ASN1_NEG_INTEGER)
|
||||||
|
BN_set_negative(ret, 1);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
420
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_int.c.grpc_back
generated
Normal file
@ -0,0 +1,420 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x)
|
||||||
|
{
|
||||||
|
return M_ASN1_INTEGER_dup(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y)
|
||||||
|
{
|
||||||
|
int neg, ret;
|
||||||
|
/* Compare signs */
|
||||||
|
neg = x->type & V_ASN1_NEG;
|
||||||
|
if (neg != (y->type & V_ASN1_NEG)) {
|
||||||
|
if (neg)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ASN1_STRING_cmp(x, y);
|
||||||
|
|
||||||
|
if (neg)
|
||||||
|
return -ret;
|
||||||
|
else
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This converts an ASN1 INTEGER into its content encoding.
|
||||||
|
* The internal representation is an ASN1_STRING whose data is a big endian
|
||||||
|
* representation of the value, ignoring the sign. The sign is determined by
|
||||||
|
* the type: V_ASN1_INTEGER for positive and V_ASN1_NEG_INTEGER for negative.
|
||||||
|
*
|
||||||
|
* Positive integers are no problem: they are almost the same as the DER
|
||||||
|
* encoding, except if the first byte is >= 0x80 we need to add a zero pad.
|
||||||
|
*
|
||||||
|
* Negative integers are a bit trickier...
|
||||||
|
* The DER representation of negative integers is in 2s complement form.
|
||||||
|
* The internal form is converted by complementing each octet and finally
|
||||||
|
* adding one to the result. This can be done less messily with a little trick.
|
||||||
|
* If the internal form has trailing zeroes then they will become FF by the
|
||||||
|
* complement and 0 by the add one (due to carry) so just copy as many trailing
|
||||||
|
* zeros to the destination as there are in the source. The carry will add one
|
||||||
|
* to the last none zero octet: so complement this octet and add one and finally
|
||||||
|
* complement any left over until you get to the start of the string.
|
||||||
|
*
|
||||||
|
* Padding is a little trickier too. If the first bytes is > 0x80 then we pad
|
||||||
|
* with 0xff. However if the first byte is 0x80 and one of the following bytes
|
||||||
|
* is non-zero we pad with 0xff. The reason for this distinction is that 0x80
|
||||||
|
* followed by optional zeros isn't padded.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
int pad = 0, ret, i, neg;
|
||||||
|
unsigned char *p, *n, pb = 0;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0);
|
||||||
|
neg = a->type & V_ASN1_NEG;
|
||||||
|
if (a->length == 0)
|
||||||
|
ret = 1;
|
||||||
|
else {
|
||||||
|
ret = a->length;
|
||||||
|
i = a->data[0];
|
||||||
|
if (ret == 1 && i == 0)
|
||||||
|
neg = 0;
|
||||||
|
if (!neg && (i > 127)) {
|
||||||
|
pad = 1;
|
||||||
|
pb = 0;
|
||||||
|
} else if (neg) {
|
||||||
|
if (i > 128) {
|
||||||
|
pad = 1;
|
||||||
|
pb = 0xFF;
|
||||||
|
} else if (i == 128) {
|
||||||
|
/*
|
||||||
|
* Special case: if any other bytes non zero we pad:
|
||||||
|
* otherwise we don't.
|
||||||
|
*/
|
||||||
|
for (i = 1; i < a->length; i++)
|
||||||
|
if (a->data[i]) {
|
||||||
|
pad = 1;
|
||||||
|
pb = 0xFF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret += pad;
|
||||||
|
}
|
||||||
|
if (pp == NULL)
|
||||||
|
return (ret);
|
||||||
|
p = *pp;
|
||||||
|
|
||||||
|
if (pad)
|
||||||
|
*(p++) = pb;
|
||||||
|
if (a->length == 0)
|
||||||
|
*(p++) = 0;
|
||||||
|
else if (!neg)
|
||||||
|
OPENSSL_memcpy(p, a->data, (unsigned int)a->length);
|
||||||
|
else {
|
||||||
|
/* Begin at the end of the encoding */
|
||||||
|
n = a->data + a->length - 1;
|
||||||
|
p += a->length - 1;
|
||||||
|
i = a->length;
|
||||||
|
/* Copy zeros to destination as long as source is zero */
|
||||||
|
while (!*n && i > 1) {
|
||||||
|
*(p--) = 0;
|
||||||
|
n--;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
/* Complement and increment next octet */
|
||||||
|
*(p--) = ((*(n--)) ^ 0xff) + 1;
|
||||||
|
i--;
|
||||||
|
/* Complement any octets left */
|
||||||
|
for (; i > 0; i--)
|
||||||
|
*(p--) = *(n--) ^ 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pp += ret;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
|
||||||
|
|
||||||
|
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
|
||||||
|
long len)
|
||||||
|
{
|
||||||
|
ASN1_INTEGER *ret = NULL;
|
||||||
|
const unsigned char *p, *pend;
|
||||||
|
unsigned char *to, *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function can handle lengths up to INT_MAX - 1, but the rest of the
|
||||||
|
* legacy ASN.1 code mixes integer types, so avoid exposing it to
|
||||||
|
* ASN1_INTEGERS with larger lengths.
|
||||||
|
*/
|
||||||
|
if (len < 0 || len > INT_MAX / 2) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((a == NULL) || ((*a) == NULL)) {
|
||||||
|
if ((ret = M_ASN1_INTEGER_new()) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
} else
|
||||||
|
ret = (*a);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
pend = p + len;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it signifies
|
||||||
|
* a missing NULL parameter.
|
||||||
|
*/
|
||||||
|
s = (unsigned char *)OPENSSL_malloc((int)len + 1);
|
||||||
|
if (s == NULL) {
|
||||||
|
i = ERR_R_MALLOC_FAILURE;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
to = s;
|
||||||
|
if (!len) {
|
||||||
|
/*
|
||||||
|
* Strictly speaking this is an illegal INTEGER but we tolerate it.
|
||||||
|
*/
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
} else if (*p & 0x80) { /* a negative number */
|
||||||
|
ret->type = V_ASN1_NEG_INTEGER;
|
||||||
|
if ((*p == 0xff) && (len != 1)) {
|
||||||
|
p++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
i = len;
|
||||||
|
p += i - 1;
|
||||||
|
to += i - 1;
|
||||||
|
while ((!*p) && i) {
|
||||||
|
*(to--) = 0;
|
||||||
|
i--;
|
||||||
|
p--;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Special case: if all zeros then the number will be of the form FF
|
||||||
|
* followed by n zero bytes: this corresponds to 1 followed by n zero
|
||||||
|
* bytes. We've already written n zeros so we just append an extra
|
||||||
|
* one and set the first byte to a 1. This is treated separately
|
||||||
|
* because it is the only case where the number of bytes is larger
|
||||||
|
* than len.
|
||||||
|
*/
|
||||||
|
if (!i) {
|
||||||
|
*s = 1;
|
||||||
|
s[len] = 0;
|
||||||
|
len++;
|
||||||
|
} else {
|
||||||
|
*(to--) = (*(p--) ^ 0xff) + 1;
|
||||||
|
i--;
|
||||||
|
for (; i > 0; i--)
|
||||||
|
*(to--) = *(p--) ^ 0xff;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
if ((*p == 0) && (len != 1)) {
|
||||||
|
p++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
OPENSSL_memcpy(s, p, (int)len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret->data != NULL)
|
||||||
|
OPENSSL_free(ret->data);
|
||||||
|
ret->data = s;
|
||||||
|
ret->length = (int)len;
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = pend;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||||
|
M_ASN1_INTEGER_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
|
||||||
|
{
|
||||||
|
if (v >= 0) {
|
||||||
|
return ASN1_INTEGER_set_uint64(a, (uint64_t) v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ASN1_INTEGER_set_uint64(a, 0 - (uint64_t) v)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a->type = V_ASN1_NEG_INTEGER;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_INTEGER_set_uint64(ASN1_INTEGER *out, uint64_t v)
|
||||||
|
{
|
||||||
|
uint8_t *const newdata = OPENSSL_malloc(sizeof(uint64_t));
|
||||||
|
if (newdata == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENSSL_free(out->data);
|
||||||
|
out->data = newdata;
|
||||||
|
v = CRYPTO_bswap8(v);
|
||||||
|
memcpy(out->data, &v, sizeof(v));
|
||||||
|
|
||||||
|
out->type = V_ASN1_INTEGER;
|
||||||
|
|
||||||
|
size_t leading_zeros;
|
||||||
|
for (leading_zeros = 0; leading_zeros < sizeof(uint64_t) - 1;
|
||||||
|
leading_zeros++) {
|
||||||
|
if (out->data[leading_zeros] != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out->length = sizeof(uint64_t) - leading_zeros;
|
||||||
|
OPENSSL_memmove(out->data, out->data + leading_zeros, out->length);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
long ASN1_INTEGER_get(const ASN1_INTEGER *a)
|
||||||
|
{
|
||||||
|
int neg = 0, i;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
return (0L);
|
||||||
|
i = a->type;
|
||||||
|
if (i == V_ASN1_NEG_INTEGER)
|
||||||
|
neg = 1;
|
||||||
|
else if (i != V_ASN1_INTEGER)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
|
||||||
|
"long larger than uint64_t");
|
||||||
|
|
||||||
|
if (a->length > (int)sizeof(uint64_t)) {
|
||||||
|
/* hmm... a bit ugly, return all ones */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t r64 = 0;
|
||||||
|
if (a->data != NULL) {
|
||||||
|
for (i = 0; i < a->length; i++) {
|
||||||
|
r64 <<= 8;
|
||||||
|
r64 |= (unsigned char)a->data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r64 > LONG_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long r = (long) r64;
|
||||||
|
if (neg)
|
||||||
|
r = -r;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
|
||||||
|
{
|
||||||
|
ASN1_INTEGER *ret;
|
||||||
|
int len, j;
|
||||||
|
|
||||||
|
if (ai == NULL)
|
||||||
|
ret = M_ASN1_INTEGER_new();
|
||||||
|
else
|
||||||
|
ret = ai;
|
||||||
|
if (ret == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (BN_is_negative(bn) && !BN_is_zero(bn))
|
||||||
|
ret->type = V_ASN1_NEG_INTEGER;
|
||||||
|
else
|
||||||
|
ret->type = V_ASN1_INTEGER;
|
||||||
|
j = BN_num_bits(bn);
|
||||||
|
len = ((j == 0) ? 0 : ((j / 8) + 1));
|
||||||
|
if (ret->length < len + 4) {
|
||||||
|
unsigned char *new_data = OPENSSL_realloc(ret->data, len + 4);
|
||||||
|
if (!new_data) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret->data = new_data;
|
||||||
|
}
|
||||||
|
ret->length = BN_bn2bin(bn, ret->data);
|
||||||
|
/* Correct zero case */
|
||||||
|
if (!ret->length) {
|
||||||
|
ret->data[0] = 0;
|
||||||
|
ret->length = 1;
|
||||||
|
}
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
if (ret != ai)
|
||||||
|
M_ASN1_INTEGER_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
|
||||||
|
{
|
||||||
|
BIGNUM *ret;
|
||||||
|
|
||||||
|
if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL)
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BN_LIB);
|
||||||
|
else if (ai->type == V_ASN1_NEG_INTEGER)
|
||||||
|
BN_set_negative(ret, 1);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
305
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_mbstr.c
generated
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/bytestring.h>
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
#include "../bytestring/internal.h"
|
||||||
|
|
||||||
|
static int is_printable(uint32_t value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions take a string in UTF8, ASCII or multibyte form and a mask
|
||||||
|
* of permissible ASN1 string types. It then works out the minimal type
|
||||||
|
* (using the order Printable < IA5 < T61 < BMP < Universal < UTF8) and
|
||||||
|
* creates a string of the correct type with the supplied data. Yes this is
|
||||||
|
* horrible: it has to be :-( The 'ncopy' form checks minimum and maximum
|
||||||
|
* size limits too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||||
|
int inform, unsigned long mask)
|
||||||
|
{
|
||||||
|
return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_BMPSTRING)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UNIVERSALSTRING)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UTF8STRING)
|
||||||
|
|
||||||
|
int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||||
|
int inform, unsigned long mask,
|
||||||
|
long minsize, long maxsize)
|
||||||
|
{
|
||||||
|
int str_type;
|
||||||
|
char free_out;
|
||||||
|
ASN1_STRING *dest;
|
||||||
|
size_t nchar = 0;
|
||||||
|
char strbuf[32];
|
||||||
|
if (len == -1)
|
||||||
|
len = strlen((const char *)in);
|
||||||
|
if (!mask)
|
||||||
|
mask = DIRSTRING_TYPE;
|
||||||
|
|
||||||
|
int (*decode_func)(CBS *, uint32_t*);
|
||||||
|
int error;
|
||||||
|
switch (inform) {
|
||||||
|
case MBSTRING_BMP:
|
||||||
|
decode_func = cbs_get_ucs2_be;
|
||||||
|
error = ASN1_R_INVALID_BMPSTRING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MBSTRING_UNIV:
|
||||||
|
decode_func = cbs_get_utf32_be;
|
||||||
|
error = ASN1_R_INVALID_UNIVERSALSTRING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MBSTRING_UTF8:
|
||||||
|
decode_func = cbs_get_utf8;
|
||||||
|
error = ASN1_R_INVALID_UTF8STRING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MBSTRING_ASC:
|
||||||
|
decode_func = cbs_get_latin1;
|
||||||
|
error = ERR_R_INTERNAL_ERROR; // Latin-1 inputs are never invalid.
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_FORMAT);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check |minsize| and |maxsize| and work out the minimal type, if any. */
|
||||||
|
CBS cbs;
|
||||||
|
CBS_init(&cbs, in, len);
|
||||||
|
size_t utf8_len = 0;
|
||||||
|
while (CBS_len(&cbs) != 0) {
|
||||||
|
uint32_t c;
|
||||||
|
if (!decode_func(&cbs, &c)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (nchar == 0 &&
|
||||||
|
(inform == MBSTRING_BMP || inform == MBSTRING_UNIV) &&
|
||||||
|
c == 0xfeff) {
|
||||||
|
/* Reject byte-order mark. We could drop it but that would mean
|
||||||
|
* adding ambiguity around whether a BOM was included or not when
|
||||||
|
* matching strings.
|
||||||
|
*
|
||||||
|
* For a little-endian UCS-2 string, the BOM will appear as 0xfffe
|
||||||
|
* and will be rejected as noncharacter, below. */
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update which output formats are still possible. */
|
||||||
|
if ((mask & B_ASN1_PRINTABLESTRING) && !is_printable(c)) {
|
||||||
|
mask &= ~B_ASN1_PRINTABLESTRING;
|
||||||
|
}
|
||||||
|
if ((mask & B_ASN1_IA5STRING) && (c > 127)) {
|
||||||
|
mask &= ~B_ASN1_IA5STRING;
|
||||||
|
}
|
||||||
|
if ((mask & B_ASN1_T61STRING) && (c > 0xff)) {
|
||||||
|
mask &= ~B_ASN1_T61STRING;
|
||||||
|
}
|
||||||
|
if ((mask & B_ASN1_BMPSTRING) && (c > 0xffff)) {
|
||||||
|
mask &= ~B_ASN1_BMPSTRING;
|
||||||
|
}
|
||||||
|
if (!mask) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nchar++;
|
||||||
|
utf8_len += cbb_get_utf8_len(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minsize > 0 && nchar < (size_t)minsize) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
|
||||||
|
BIO_snprintf(strbuf, sizeof strbuf, "%ld", minsize);
|
||||||
|
ERR_add_error_data(2, "minsize=", strbuf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxsize > 0 && nchar > (size_t)maxsize) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
|
||||||
|
BIO_snprintf(strbuf, sizeof strbuf, "%ld", maxsize);
|
||||||
|
ERR_add_error_data(2, "maxsize=", strbuf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now work out output format and string type */
|
||||||
|
int (*encode_func)(CBB *, uint32_t) = cbb_add_latin1;
|
||||||
|
size_t size_estimate = nchar;
|
||||||
|
int outform = MBSTRING_ASC;
|
||||||
|
if (mask & B_ASN1_PRINTABLESTRING) {
|
||||||
|
str_type = V_ASN1_PRINTABLESTRING;
|
||||||
|
} else if (mask & B_ASN1_IA5STRING) {
|
||||||
|
str_type = V_ASN1_IA5STRING;
|
||||||
|
} else if (mask & B_ASN1_T61STRING) {
|
||||||
|
str_type = V_ASN1_T61STRING;
|
||||||
|
} else if (mask & B_ASN1_BMPSTRING) {
|
||||||
|
str_type = V_ASN1_BMPSTRING;
|
||||||
|
outform = MBSTRING_BMP;
|
||||||
|
encode_func = cbb_add_ucs2_be;
|
||||||
|
size_estimate = 2 * nchar;
|
||||||
|
} else if (mask & B_ASN1_UNIVERSALSTRING) {
|
||||||
|
str_type = V_ASN1_UNIVERSALSTRING;
|
||||||
|
encode_func = cbb_add_utf32_be;
|
||||||
|
size_estimate = 4 * nchar;
|
||||||
|
outform = MBSTRING_UNIV;
|
||||||
|
} else {
|
||||||
|
str_type = V_ASN1_UTF8STRING;
|
||||||
|
outform = MBSTRING_UTF8;
|
||||||
|
encode_func = cbb_add_utf8;
|
||||||
|
size_estimate = utf8_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!out)
|
||||||
|
return str_type;
|
||||||
|
if (*out) {
|
||||||
|
free_out = 0;
|
||||||
|
dest = *out;
|
||||||
|
if (dest->data) {
|
||||||
|
dest->length = 0;
|
||||||
|
OPENSSL_free(dest->data);
|
||||||
|
dest->data = NULL;
|
||||||
|
}
|
||||||
|
dest->type = str_type;
|
||||||
|
} else {
|
||||||
|
free_out = 1;
|
||||||
|
dest = ASN1_STRING_type_new(str_type);
|
||||||
|
if (!dest) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*out = dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If both the same type just copy across */
|
||||||
|
if (inform == outform) {
|
||||||
|
if (!ASN1_STRING_set(dest, in, len)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return str_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBB cbb;
|
||||||
|
if (!CBB_init(&cbb, size_estimate + 1)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
CBS_init(&cbs, in, len);
|
||||||
|
while (CBS_len(&cbs) != 0) {
|
||||||
|
uint32_t c;
|
||||||
|
if (!decode_func(&cbs, &c) ||
|
||||||
|
!encode_func(&cbb, c)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint8_t *data = NULL;
|
||||||
|
size_t data_len;
|
||||||
|
if (/* OpenSSL historically NUL-terminated this value with a single byte,
|
||||||
|
* even for |MBSTRING_BMP| and |MBSTRING_UNIV|. */
|
||||||
|
!CBB_add_u8(&cbb, 0) ||
|
||||||
|
!CBB_finish(&cbb, &data, &data_len) ||
|
||||||
|
data_len < 1 ||
|
||||||
|
data_len > INT_MAX) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
|
||||||
|
OPENSSL_free(data);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
dest->length = (int)(data_len - 1);
|
||||||
|
dest->data = data;
|
||||||
|
return str_type;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (free_out)
|
||||||
|
ASN1_STRING_free(dest);
|
||||||
|
CBB_cleanup(&cbb);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return 1 if the character is permitted in a PrintableString */
|
||||||
|
static int is_printable(uint32_t value)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
if (value > 0x7f)
|
||||||
|
return 0;
|
||||||
|
ch = (int)value;
|
||||||
|
/*
|
||||||
|
* Note: we can't use 'isalnum' because certain accented characters may
|
||||||
|
* count as alphanumeric in some environments.
|
||||||
|
*/
|
||||||
|
if ((ch >= 'a') && (ch <= 'z'))
|
||||||
|
return 1;
|
||||||
|
if ((ch >= 'A') && (ch <= 'Z'))
|
||||||
|
return 1;
|
||||||
|
if ((ch >= '0') && (ch <= '9'))
|
||||||
|
return 1;
|
||||||
|
if ((ch == ' ') || strchr("'()+,-./:=?", ch))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
305
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_mbstr.c.grpc_back
generated
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl/bytestring.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
#include "../bytestring/internal.h"
|
||||||
|
|
||||||
|
static int is_printable(uint32_t value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions take a string in UTF8, ASCII or multibyte form and a mask
|
||||||
|
* of permissible ASN1 string types. It then works out the minimal type
|
||||||
|
* (using the order Printable < IA5 < T61 < BMP < Universal < UTF8) and
|
||||||
|
* creates a string of the correct type with the supplied data. Yes this is
|
||||||
|
* horrible: it has to be :-( The 'ncopy' form checks minimum and maximum
|
||||||
|
* size limits too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||||
|
int inform, unsigned long mask)
|
||||||
|
{
|
||||||
|
return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_BMPSTRING)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UNIVERSALSTRING)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UTF8STRING)
|
||||||
|
|
||||||
|
int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||||
|
int inform, unsigned long mask,
|
||||||
|
long minsize, long maxsize)
|
||||||
|
{
|
||||||
|
int str_type;
|
||||||
|
char free_out;
|
||||||
|
ASN1_STRING *dest;
|
||||||
|
size_t nchar = 0;
|
||||||
|
char strbuf[32];
|
||||||
|
if (len == -1)
|
||||||
|
len = strlen((const char *)in);
|
||||||
|
if (!mask)
|
||||||
|
mask = DIRSTRING_TYPE;
|
||||||
|
|
||||||
|
int (*decode_func)(CBS *, uint32_t*);
|
||||||
|
int error;
|
||||||
|
switch (inform) {
|
||||||
|
case MBSTRING_BMP:
|
||||||
|
decode_func = cbs_get_ucs2_be;
|
||||||
|
error = ASN1_R_INVALID_BMPSTRING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MBSTRING_UNIV:
|
||||||
|
decode_func = cbs_get_utf32_be;
|
||||||
|
error = ASN1_R_INVALID_UNIVERSALSTRING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MBSTRING_UTF8:
|
||||||
|
decode_func = cbs_get_utf8;
|
||||||
|
error = ASN1_R_INVALID_UTF8STRING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MBSTRING_ASC:
|
||||||
|
decode_func = cbs_get_latin1;
|
||||||
|
error = ERR_R_INTERNAL_ERROR; // Latin-1 inputs are never invalid.
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_FORMAT);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check |minsize| and |maxsize| and work out the minimal type, if any. */
|
||||||
|
CBS cbs;
|
||||||
|
CBS_init(&cbs, in, len);
|
||||||
|
size_t utf8_len = 0;
|
||||||
|
while (CBS_len(&cbs) != 0) {
|
||||||
|
uint32_t c;
|
||||||
|
if (!decode_func(&cbs, &c)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (nchar == 0 &&
|
||||||
|
(inform == MBSTRING_BMP || inform == MBSTRING_UNIV) &&
|
||||||
|
c == 0xfeff) {
|
||||||
|
/* Reject byte-order mark. We could drop it but that would mean
|
||||||
|
* adding ambiguity around whether a BOM was included or not when
|
||||||
|
* matching strings.
|
||||||
|
*
|
||||||
|
* For a little-endian UCS-2 string, the BOM will appear as 0xfffe
|
||||||
|
* and will be rejected as noncharacter, below. */
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update which output formats are still possible. */
|
||||||
|
if ((mask & B_ASN1_PRINTABLESTRING) && !is_printable(c)) {
|
||||||
|
mask &= ~B_ASN1_PRINTABLESTRING;
|
||||||
|
}
|
||||||
|
if ((mask & B_ASN1_IA5STRING) && (c > 127)) {
|
||||||
|
mask &= ~B_ASN1_IA5STRING;
|
||||||
|
}
|
||||||
|
if ((mask & B_ASN1_T61STRING) && (c > 0xff)) {
|
||||||
|
mask &= ~B_ASN1_T61STRING;
|
||||||
|
}
|
||||||
|
if ((mask & B_ASN1_BMPSTRING) && (c > 0xffff)) {
|
||||||
|
mask &= ~B_ASN1_BMPSTRING;
|
||||||
|
}
|
||||||
|
if (!mask) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nchar++;
|
||||||
|
utf8_len += cbb_get_utf8_len(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minsize > 0 && nchar < (size_t)minsize) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
|
||||||
|
BIO_snprintf(strbuf, sizeof strbuf, "%ld", minsize);
|
||||||
|
ERR_add_error_data(2, "minsize=", strbuf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxsize > 0 && nchar > (size_t)maxsize) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
|
||||||
|
BIO_snprintf(strbuf, sizeof strbuf, "%ld", maxsize);
|
||||||
|
ERR_add_error_data(2, "maxsize=", strbuf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now work out output format and string type */
|
||||||
|
int (*encode_func)(CBB *, uint32_t) = cbb_add_latin1;
|
||||||
|
size_t size_estimate = nchar;
|
||||||
|
int outform = MBSTRING_ASC;
|
||||||
|
if (mask & B_ASN1_PRINTABLESTRING) {
|
||||||
|
str_type = V_ASN1_PRINTABLESTRING;
|
||||||
|
} else if (mask & B_ASN1_IA5STRING) {
|
||||||
|
str_type = V_ASN1_IA5STRING;
|
||||||
|
} else if (mask & B_ASN1_T61STRING) {
|
||||||
|
str_type = V_ASN1_T61STRING;
|
||||||
|
} else if (mask & B_ASN1_BMPSTRING) {
|
||||||
|
str_type = V_ASN1_BMPSTRING;
|
||||||
|
outform = MBSTRING_BMP;
|
||||||
|
encode_func = cbb_add_ucs2_be;
|
||||||
|
size_estimate = 2 * nchar;
|
||||||
|
} else if (mask & B_ASN1_UNIVERSALSTRING) {
|
||||||
|
str_type = V_ASN1_UNIVERSALSTRING;
|
||||||
|
encode_func = cbb_add_utf32_be;
|
||||||
|
size_estimate = 4 * nchar;
|
||||||
|
outform = MBSTRING_UNIV;
|
||||||
|
} else {
|
||||||
|
str_type = V_ASN1_UTF8STRING;
|
||||||
|
outform = MBSTRING_UTF8;
|
||||||
|
encode_func = cbb_add_utf8;
|
||||||
|
size_estimate = utf8_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!out)
|
||||||
|
return str_type;
|
||||||
|
if (*out) {
|
||||||
|
free_out = 0;
|
||||||
|
dest = *out;
|
||||||
|
if (dest->data) {
|
||||||
|
dest->length = 0;
|
||||||
|
OPENSSL_free(dest->data);
|
||||||
|
dest->data = NULL;
|
||||||
|
}
|
||||||
|
dest->type = str_type;
|
||||||
|
} else {
|
||||||
|
free_out = 1;
|
||||||
|
dest = ASN1_STRING_type_new(str_type);
|
||||||
|
if (!dest) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*out = dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If both the same type just copy across */
|
||||||
|
if (inform == outform) {
|
||||||
|
if (!ASN1_STRING_set(dest, in, len)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return str_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBB cbb;
|
||||||
|
if (!CBB_init(&cbb, size_estimate + 1)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
CBS_init(&cbs, in, len);
|
||||||
|
while (CBS_len(&cbs) != 0) {
|
||||||
|
uint32_t c;
|
||||||
|
if (!decode_func(&cbs, &c) ||
|
||||||
|
!encode_func(&cbb, c)) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint8_t *data = NULL;
|
||||||
|
size_t data_len;
|
||||||
|
if (/* OpenSSL historically NUL-terminated this value with a single byte,
|
||||||
|
* even for |MBSTRING_BMP| and |MBSTRING_UNIV|. */
|
||||||
|
!CBB_add_u8(&cbb, 0) ||
|
||||||
|
!CBB_finish(&cbb, &data, &data_len) ||
|
||||||
|
data_len < 1 ||
|
||||||
|
data_len > INT_MAX) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
|
||||||
|
OPENSSL_free(data);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
dest->length = (int)(data_len - 1);
|
||||||
|
dest->data = data;
|
||||||
|
return str_type;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (free_out)
|
||||||
|
ASN1_STRING_free(dest);
|
||||||
|
CBB_cleanup(&cbb);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return 1 if the character is permitted in a PrintableString */
|
||||||
|
static int is_printable(uint32_t value)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
if (value > 0x7f)
|
||||||
|
return 0;
|
||||||
|
ch = (int)value;
|
||||||
|
/*
|
||||||
|
* Note: we can't use 'isalnum' because certain accented characters may
|
||||||
|
* count as alphanumeric in some environments.
|
||||||
|
*/
|
||||||
|
if ((ch >= 'a') && (ch <= 'z'))
|
||||||
|
return 1;
|
||||||
|
if ((ch >= 'A') && (ch <= 'Z'))
|
||||||
|
return 1;
|
||||||
|
if ((ch >= '0') && (ch <= '9'))
|
||||||
|
return 1;
|
||||||
|
if ((ch == ' ') || strchr("'()+,-./:=?", ch))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
286
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_object.c
generated
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
#include <openssl_grpc/obj.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
unsigned char *p, *allocated = NULL;
|
||||||
|
int objsize;
|
||||||
|
|
||||||
|
if ((a == NULL) || (a->data == NULL))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
objsize = ASN1_object_size(0, a->length, V_ASN1_OBJECT);
|
||||||
|
if (pp == NULL || objsize == -1)
|
||||||
|
return objsize;
|
||||||
|
|
||||||
|
if (*pp == NULL) {
|
||||||
|
if ((p = allocated = OPENSSL_malloc(objsize)) == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p = *pp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_put_object(&p, 0, a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
|
||||||
|
OPENSSL_memcpy(p, a->data, a->length);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If a new buffer was allocated, just return it back.
|
||||||
|
* If not, return the incremented buffer pointer.
|
||||||
|
*/
|
||||||
|
*pp = allocated != NULL ? allocated : p + a->length;
|
||||||
|
return objsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
|
||||||
|
{
|
||||||
|
return OBJ_obj2txt(buf, buf_len, a, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
|
||||||
|
{
|
||||||
|
char buf[80], *p = buf;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ((a == NULL) || (a->data == NULL))
|
||||||
|
return (BIO_write(bp, "NULL", 4));
|
||||||
|
i = i2t_ASN1_OBJECT(buf, sizeof buf, a);
|
||||||
|
if (i > (int)(sizeof(buf) - 1)) {
|
||||||
|
p = OPENSSL_malloc(i + 1);
|
||||||
|
if (!p)
|
||||||
|
return -1;
|
||||||
|
i2t_ASN1_OBJECT(p, i + 1, a);
|
||||||
|
}
|
||||||
|
if (i <= 0)
|
||||||
|
return BIO_write(bp, "<INVALID>", 9);
|
||||||
|
BIO_write(bp, p, i);
|
||||||
|
if (p != buf)
|
||||||
|
OPENSSL_free(p);
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||||
|
long length)
|
||||||
|
{
|
||||||
|
const unsigned char *p;
|
||||||
|
long len;
|
||||||
|
int tag, xclass;
|
||||||
|
int inf, i;
|
||||||
|
ASN1_OBJECT *ret = NULL;
|
||||||
|
p = *pp;
|
||||||
|
inf = ASN1_get_object(&p, &len, &tag, &xclass, length);
|
||||||
|
if (inf & 0x80) {
|
||||||
|
i = ASN1_R_BAD_OBJECT_HEADER;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag != V_ASN1_OBJECT) {
|
||||||
|
i = ASN1_R_EXPECTING_AN_OBJECT;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret = c2i_ASN1_OBJECT(a, &p, len);
|
||||||
|
if (ret)
|
||||||
|
*pp = p;
|
||||||
|
return ret;
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||||
|
long len)
|
||||||
|
{
|
||||||
|
ASN1_OBJECT *ret = NULL;
|
||||||
|
const unsigned char *p;
|
||||||
|
unsigned char *data;
|
||||||
|
int i, length;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanity check OID encoding. Need at least one content octet. MSB must
|
||||||
|
* be clear in the last octet. can't have leading 0x80 in subidentifiers,
|
||||||
|
* see: X.690 8.19.2
|
||||||
|
*/
|
||||||
|
if (len <= 0 || len > INT_MAX || pp == NULL || (p = *pp) == NULL ||
|
||||||
|
p[len - 1] & 0x80) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_OBJECT_ENCODING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Now 0 < len <= INT_MAX, so the cast is safe. */
|
||||||
|
length = (int)len;
|
||||||
|
for (i = 0; i < length; i++, p++) {
|
||||||
|
if (*p == 0x80 && (!i || !(p[-1] & 0x80))) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_OBJECT_ENCODING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* only the ASN1_OBJECTs from the 'table' will have values for ->sn or
|
||||||
|
* ->ln
|
||||||
|
*/
|
||||||
|
if ((a == NULL) || ((*a) == NULL) ||
|
||||||
|
!((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC)) {
|
||||||
|
if ((ret = ASN1_OBJECT_new()) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
} else
|
||||||
|
ret = (*a);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
/* detach data from object */
|
||||||
|
data = (unsigned char *)ret->data;
|
||||||
|
ret->data = NULL;
|
||||||
|
/* once detached we can change it */
|
||||||
|
if ((data == NULL) || (ret->length < length)) {
|
||||||
|
ret->length = 0;
|
||||||
|
if (data != NULL)
|
||||||
|
OPENSSL_free(data);
|
||||||
|
data = (unsigned char *)OPENSSL_malloc(length);
|
||||||
|
if (data == NULL) {
|
||||||
|
i = ERR_R_MALLOC_FAILURE;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret->flags |= ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||||
|
}
|
||||||
|
OPENSSL_memcpy(data, p, length);
|
||||||
|
/* reattach data to object, after which it remains const */
|
||||||
|
ret->data = data;
|
||||||
|
ret->length = length;
|
||||||
|
ret->sn = NULL;
|
||||||
|
ret->ln = NULL;
|
||||||
|
/* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
|
||||||
|
p += length;
|
||||||
|
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||||
|
ASN1_OBJECT_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *ASN1_OBJECT_new(void)
|
||||||
|
{
|
||||||
|
ASN1_OBJECT *ret;
|
||||||
|
|
||||||
|
ret = (ASN1_OBJECT *)OPENSSL_malloc(sizeof(ASN1_OBJECT));
|
||||||
|
if (ret == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ret->length = 0;
|
||||||
|
ret->data = NULL;
|
||||||
|
ret->nid = 0;
|
||||||
|
ret->sn = NULL;
|
||||||
|
ret->ln = NULL;
|
||||||
|
ret->flags = ASN1_OBJECT_FLAG_DYNAMIC;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_OBJECT_free(ASN1_OBJECT *a)
|
||||||
|
{
|
||||||
|
if (a == NULL)
|
||||||
|
return;
|
||||||
|
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) {
|
||||||
|
#ifndef CONST_STRICT /* disable purely for compile-time strict
|
||||||
|
* const checking. Doing this on a "real"
|
||||||
|
* compile will cause memory leaks */
|
||||||
|
if (a->sn != NULL)
|
||||||
|
OPENSSL_free((void *)a->sn);
|
||||||
|
if (a->ln != NULL)
|
||||||
|
OPENSSL_free((void *)a->ln);
|
||||||
|
#endif
|
||||||
|
a->sn = a->ln = NULL;
|
||||||
|
}
|
||||||
|
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) {
|
||||||
|
if (a->data != NULL)
|
||||||
|
OPENSSL_free((void *)a->data);
|
||||||
|
a->data = NULL;
|
||||||
|
a->length = 0;
|
||||||
|
}
|
||||||
|
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC)
|
||||||
|
OPENSSL_free(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
|
||||||
|
const char *sn, const char *ln)
|
||||||
|
{
|
||||||
|
ASN1_OBJECT o;
|
||||||
|
|
||||||
|
o.sn = sn;
|
||||||
|
o.ln = ln;
|
||||||
|
o.data = data;
|
||||||
|
o.nid = nid;
|
||||||
|
o.length = len;
|
||||||
|
o.flags = ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
|
||||||
|
ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||||
|
return (OBJ_dup(&o));
|
||||||
|
}
|
||||||
286
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_object.c.grpc_back
generated
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
#include <openssl/obj.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
|
||||||
|
{
|
||||||
|
unsigned char *p, *allocated = NULL;
|
||||||
|
int objsize;
|
||||||
|
|
||||||
|
if ((a == NULL) || (a->data == NULL))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
objsize = ASN1_object_size(0, a->length, V_ASN1_OBJECT);
|
||||||
|
if (pp == NULL || objsize == -1)
|
||||||
|
return objsize;
|
||||||
|
|
||||||
|
if (*pp == NULL) {
|
||||||
|
if ((p = allocated = OPENSSL_malloc(objsize)) == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p = *pp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_put_object(&p, 0, a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
|
||||||
|
OPENSSL_memcpy(p, a->data, a->length);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If a new buffer was allocated, just return it back.
|
||||||
|
* If not, return the incremented buffer pointer.
|
||||||
|
*/
|
||||||
|
*pp = allocated != NULL ? allocated : p + a->length;
|
||||||
|
return objsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
|
||||||
|
{
|
||||||
|
return OBJ_obj2txt(buf, buf_len, a, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
|
||||||
|
{
|
||||||
|
char buf[80], *p = buf;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ((a == NULL) || (a->data == NULL))
|
||||||
|
return (BIO_write(bp, "NULL", 4));
|
||||||
|
i = i2t_ASN1_OBJECT(buf, sizeof buf, a);
|
||||||
|
if (i > (int)(sizeof(buf) - 1)) {
|
||||||
|
p = OPENSSL_malloc(i + 1);
|
||||||
|
if (!p)
|
||||||
|
return -1;
|
||||||
|
i2t_ASN1_OBJECT(p, i + 1, a);
|
||||||
|
}
|
||||||
|
if (i <= 0)
|
||||||
|
return BIO_write(bp, "<INVALID>", 9);
|
||||||
|
BIO_write(bp, p, i);
|
||||||
|
if (p != buf)
|
||||||
|
OPENSSL_free(p);
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||||
|
long length)
|
||||||
|
{
|
||||||
|
const unsigned char *p;
|
||||||
|
long len;
|
||||||
|
int tag, xclass;
|
||||||
|
int inf, i;
|
||||||
|
ASN1_OBJECT *ret = NULL;
|
||||||
|
p = *pp;
|
||||||
|
inf = ASN1_get_object(&p, &len, &tag, &xclass, length);
|
||||||
|
if (inf & 0x80) {
|
||||||
|
i = ASN1_R_BAD_OBJECT_HEADER;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag != V_ASN1_OBJECT) {
|
||||||
|
i = ASN1_R_EXPECTING_AN_OBJECT;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret = c2i_ASN1_OBJECT(a, &p, len);
|
||||||
|
if (ret)
|
||||||
|
*pp = p;
|
||||||
|
return ret;
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||||
|
long len)
|
||||||
|
{
|
||||||
|
ASN1_OBJECT *ret = NULL;
|
||||||
|
const unsigned char *p;
|
||||||
|
unsigned char *data;
|
||||||
|
int i, length;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanity check OID encoding. Need at least one content octet. MSB must
|
||||||
|
* be clear in the last octet. can't have leading 0x80 in subidentifiers,
|
||||||
|
* see: X.690 8.19.2
|
||||||
|
*/
|
||||||
|
if (len <= 0 || len > INT_MAX || pp == NULL || (p = *pp) == NULL ||
|
||||||
|
p[len - 1] & 0x80) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_OBJECT_ENCODING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Now 0 < len <= INT_MAX, so the cast is safe. */
|
||||||
|
length = (int)len;
|
||||||
|
for (i = 0; i < length; i++, p++) {
|
||||||
|
if (*p == 0x80 && (!i || !(p[-1] & 0x80))) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_OBJECT_ENCODING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* only the ASN1_OBJECTs from the 'table' will have values for ->sn or
|
||||||
|
* ->ln
|
||||||
|
*/
|
||||||
|
if ((a == NULL) || ((*a) == NULL) ||
|
||||||
|
!((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC)) {
|
||||||
|
if ((ret = ASN1_OBJECT_new()) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
} else
|
||||||
|
ret = (*a);
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
/* detach data from object */
|
||||||
|
data = (unsigned char *)ret->data;
|
||||||
|
ret->data = NULL;
|
||||||
|
/* once detached we can change it */
|
||||||
|
if ((data == NULL) || (ret->length < length)) {
|
||||||
|
ret->length = 0;
|
||||||
|
if (data != NULL)
|
||||||
|
OPENSSL_free(data);
|
||||||
|
data = (unsigned char *)OPENSSL_malloc(length);
|
||||||
|
if (data == NULL) {
|
||||||
|
i = ERR_R_MALLOC_FAILURE;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ret->flags |= ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||||
|
}
|
||||||
|
OPENSSL_memcpy(data, p, length);
|
||||||
|
/* reattach data to object, after which it remains const */
|
||||||
|
ret->data = data;
|
||||||
|
ret->length = length;
|
||||||
|
ret->sn = NULL;
|
||||||
|
ret->ln = NULL;
|
||||||
|
/* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
|
||||||
|
p += length;
|
||||||
|
|
||||||
|
if (a != NULL)
|
||||||
|
(*a) = ret;
|
||||||
|
*pp = p;
|
||||||
|
return (ret);
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, i);
|
||||||
|
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||||
|
ASN1_OBJECT_free(ret);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *ASN1_OBJECT_new(void)
|
||||||
|
{
|
||||||
|
ASN1_OBJECT *ret;
|
||||||
|
|
||||||
|
ret = (ASN1_OBJECT *)OPENSSL_malloc(sizeof(ASN1_OBJECT));
|
||||||
|
if (ret == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ret->length = 0;
|
||||||
|
ret->data = NULL;
|
||||||
|
ret->nid = 0;
|
||||||
|
ret->sn = NULL;
|
||||||
|
ret->ln = NULL;
|
||||||
|
ret->flags = ASN1_OBJECT_FLAG_DYNAMIC;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_OBJECT_free(ASN1_OBJECT *a)
|
||||||
|
{
|
||||||
|
if (a == NULL)
|
||||||
|
return;
|
||||||
|
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) {
|
||||||
|
#ifndef CONST_STRICT /* disable purely for compile-time strict
|
||||||
|
* const checking. Doing this on a "real"
|
||||||
|
* compile will cause memory leaks */
|
||||||
|
if (a->sn != NULL)
|
||||||
|
OPENSSL_free((void *)a->sn);
|
||||||
|
if (a->ln != NULL)
|
||||||
|
OPENSSL_free((void *)a->ln);
|
||||||
|
#endif
|
||||||
|
a->sn = a->ln = NULL;
|
||||||
|
}
|
||||||
|
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) {
|
||||||
|
if (a->data != NULL)
|
||||||
|
OPENSSL_free((void *)a->data);
|
||||||
|
a->data = NULL;
|
||||||
|
a->length = 0;
|
||||||
|
}
|
||||||
|
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC)
|
||||||
|
OPENSSL_free(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
|
||||||
|
const char *sn, const char *ln)
|
||||||
|
{
|
||||||
|
ASN1_OBJECT o;
|
||||||
|
|
||||||
|
o.sn = sn;
|
||||||
|
o.ln = ln;
|
||||||
|
o.data = data;
|
||||||
|
o.nid = nid;
|
||||||
|
o.length = len;
|
||||||
|
o.flags = ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
|
||||||
|
ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||||
|
return (OBJ_dup(&o));
|
||||||
|
}
|
||||||
77
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_octet.c
generated
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *x)
|
||||||
|
{
|
||||||
|
return M_ASN1_OCTET_STRING_dup(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
|
||||||
|
const ASN1_OCTET_STRING *b)
|
||||||
|
{
|
||||||
|
return M_ASN1_OCTET_STRING_cmp(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,
|
||||||
|
int len)
|
||||||
|
{
|
||||||
|
return M_ASN1_OCTET_STRING_set(x, d, len);
|
||||||
|
}
|
||||||
77
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_octet.c.grpc_back
generated
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *x)
|
||||||
|
{
|
||||||
|
return M_ASN1_OCTET_STRING_dup(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
|
||||||
|
const ASN1_OCTET_STRING *b)
|
||||||
|
{
|
||||||
|
return M_ASN1_OCTET_STRING_cmp(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,
|
||||||
|
int len)
|
||||||
|
{
|
||||||
|
return M_ASN1_OCTET_STRING_set(x, d, len);
|
||||||
|
}
|
||||||
93
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_print.c
generated
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
int ASN1_PRINTABLE_type(const unsigned char *s, int len)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
int ia5 = 0;
|
||||||
|
int t61 = 0;
|
||||||
|
|
||||||
|
if (len <= 0)
|
||||||
|
len = -1;
|
||||||
|
if (s == NULL)
|
||||||
|
return (V_ASN1_PRINTABLESTRING);
|
||||||
|
|
||||||
|
while ((*s) && (len-- != 0)) {
|
||||||
|
c = *(s++);
|
||||||
|
if (!(((c >= 'a') && (c <= 'z')) ||
|
||||||
|
((c >= 'A') && (c <= 'Z')) ||
|
||||||
|
(c == ' ') ||
|
||||||
|
((c >= '0') && (c <= '9')) ||
|
||||||
|
(c == ' ') || (c == '\'') ||
|
||||||
|
(c == '(') || (c == ')') ||
|
||||||
|
(c == '+') || (c == ',') ||
|
||||||
|
(c == '-') || (c == '.') ||
|
||||||
|
(c == '/') || (c == ':') || (c == '=') || (c == '?')))
|
||||||
|
ia5 = 1;
|
||||||
|
if (c & 0x80)
|
||||||
|
t61 = 1;
|
||||||
|
}
|
||||||
|
if (t61)
|
||||||
|
return (V_ASN1_T61STRING);
|
||||||
|
if (ia5)
|
||||||
|
return (V_ASN1_IA5STRING);
|
||||||
|
return (V_ASN1_PRINTABLESTRING);
|
||||||
|
}
|
||||||
93
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_print.c.grpc_back
generated
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
int ASN1_PRINTABLE_type(const unsigned char *s, int len)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
int ia5 = 0;
|
||||||
|
int t61 = 0;
|
||||||
|
|
||||||
|
if (len <= 0)
|
||||||
|
len = -1;
|
||||||
|
if (s == NULL)
|
||||||
|
return (V_ASN1_PRINTABLESTRING);
|
||||||
|
|
||||||
|
while ((*s) && (len-- != 0)) {
|
||||||
|
c = *(s++);
|
||||||
|
if (!(((c >= 'a') && (c <= 'z')) ||
|
||||||
|
((c >= 'A') && (c <= 'Z')) ||
|
||||||
|
(c == ' ') ||
|
||||||
|
((c >= '0') && (c <= '9')) ||
|
||||||
|
(c == ' ') || (c == '\'') ||
|
||||||
|
(c == '(') || (c == ')') ||
|
||||||
|
(c == '+') || (c == ',') ||
|
||||||
|
(c == '-') || (c == '.') ||
|
||||||
|
(c == '/') || (c == ':') || (c == '=') || (c == '?')))
|
||||||
|
ia5 = 1;
|
||||||
|
if (c & 0x80)
|
||||||
|
t61 = 1;
|
||||||
|
}
|
||||||
|
if (t61)
|
||||||
|
return (V_ASN1_T61STRING);
|
||||||
|
if (ia5)
|
||||||
|
return (V_ASN1_IA5STRING);
|
||||||
|
return (V_ASN1_PRINTABLESTRING);
|
||||||
|
}
|
||||||
313
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_strnid.c
generated
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <stdlib.h> /* For bsearch */
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
#include <openssl_grpc/obj.h>
|
||||||
|
#include <openssl_grpc/stack.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_STRING_TABLE)
|
||||||
|
|
||||||
|
static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
|
||||||
|
static void st_free(ASN1_STRING_TABLE *tbl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the global mask for the mbstring functions: this is use to mask
|
||||||
|
* out certain types (such as BMPString and UTF8String) because certain
|
||||||
|
* software (e.g. Netscape) has problems with them.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static unsigned long global_mask = B_ASN1_UTF8STRING;
|
||||||
|
|
||||||
|
void ASN1_STRING_set_default_mask(unsigned long mask)
|
||||||
|
{
|
||||||
|
global_mask = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long ASN1_STRING_get_default_mask(void)
|
||||||
|
{
|
||||||
|
return global_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function sets the default to various "flavours" of configuration.
|
||||||
|
* based on an ASCII string. Currently this is: MASK:XXXX : a numerical mask
|
||||||
|
* value. nobmp : Don't use BMPStrings (just Printable, T61). pkix : PKIX
|
||||||
|
* recommendation in RFC2459. utf8only : only use UTF8Strings (RFC2459
|
||||||
|
* recommendation for 2004). default: the default value, Printable, T61, BMP.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ASN1_STRING_set_default_mask_asc(const char *p)
|
||||||
|
{
|
||||||
|
unsigned long mask;
|
||||||
|
char *end;
|
||||||
|
if (!strncmp(p, "MASK:", 5)) {
|
||||||
|
if (!p[5])
|
||||||
|
return 0;
|
||||||
|
mask = strtoul(p + 5, &end, 0);
|
||||||
|
if (*end)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcmp(p, "nombstr"))
|
||||||
|
mask = ~((unsigned long)(B_ASN1_BMPSTRING | B_ASN1_UTF8STRING));
|
||||||
|
else if (!strcmp(p, "pkix"))
|
||||||
|
mask = ~((unsigned long)B_ASN1_T61STRING);
|
||||||
|
else if (!strcmp(p, "utf8only"))
|
||||||
|
mask = B_ASN1_UTF8STRING;
|
||||||
|
else if (!strcmp(p, "default"))
|
||||||
|
mask = 0xFFFFFFFFL;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
ASN1_STRING_set_default_mask(mask);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following function generates an ASN1_STRING based on limits in a
|
||||||
|
* table. Frequently the types and length of an ASN1_STRING are restricted by
|
||||||
|
* a corresponding OID. For example certificates and certificate requests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
|
||||||
|
const unsigned char *in, int inlen,
|
||||||
|
int inform, int nid)
|
||||||
|
{
|
||||||
|
ASN1_STRING_TABLE *tbl;
|
||||||
|
ASN1_STRING *str = NULL;
|
||||||
|
unsigned long mask;
|
||||||
|
int ret;
|
||||||
|
if (!out)
|
||||||
|
out = &str;
|
||||||
|
tbl = ASN1_STRING_TABLE_get(nid);
|
||||||
|
if (tbl) {
|
||||||
|
mask = tbl->mask;
|
||||||
|
if (!(tbl->flags & STABLE_NO_MASK))
|
||||||
|
mask &= global_mask;
|
||||||
|
ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask,
|
||||||
|
tbl->minsize, tbl->maxsize);
|
||||||
|
} else
|
||||||
|
ret =
|
||||||
|
ASN1_mbstring_copy(out, in, inlen, inform,
|
||||||
|
DIRSTRING_TYPE & global_mask);
|
||||||
|
if (ret <= 0)
|
||||||
|
return NULL;
|
||||||
|
return *out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now the tables and helper functions for the string table:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* size limits: this stuff is taken straight from RFC3280 */
|
||||||
|
|
||||||
|
#define ub_name 32768
|
||||||
|
#define ub_common_name 64
|
||||||
|
#define ub_locality_name 128
|
||||||
|
#define ub_state_name 128
|
||||||
|
#define ub_organization_name 64
|
||||||
|
#define ub_organization_unit_name 64
|
||||||
|
#define ub_title 64
|
||||||
|
#define ub_email_address 128
|
||||||
|
#define ub_serial_number 64
|
||||||
|
|
||||||
|
/* This table must be kept in NID order */
|
||||||
|
|
||||||
|
static const ASN1_STRING_TABLE tbl_standard[] = {
|
||||||
|
{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||||
|
{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE,
|
||||||
|
0},
|
||||||
|
{NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING,
|
||||||
|
STABLE_NO_MASK},
|
||||||
|
{NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
|
||||||
|
{NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
|
||||||
|
{NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING,
|
||||||
|
STABLE_NO_MASK},
|
||||||
|
{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
|
||||||
|
{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||||
|
{NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
|
||||||
|
{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sk_table_cmp(const ASN1_STRING_TABLE **a,
|
||||||
|
const ASN1_STRING_TABLE **b)
|
||||||
|
{
|
||||||
|
return (*a)->nid - (*b)->nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int table_cmp(const void *in_a, const void *in_b)
|
||||||
|
{
|
||||||
|
const ASN1_STRING_TABLE *a = in_a;
|
||||||
|
const ASN1_STRING_TABLE *b = in_b;
|
||||||
|
return a->nid - b->nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||||
|
{
|
||||||
|
int found;
|
||||||
|
size_t idx;
|
||||||
|
ASN1_STRING_TABLE *ttmp;
|
||||||
|
ASN1_STRING_TABLE fnd;
|
||||||
|
fnd.nid = nid;
|
||||||
|
|
||||||
|
ttmp =
|
||||||
|
bsearch(&fnd, tbl_standard,
|
||||||
|
sizeof(tbl_standard) / sizeof(ASN1_STRING_TABLE),
|
||||||
|
sizeof(ASN1_STRING_TABLE), table_cmp);
|
||||||
|
if (ttmp)
|
||||||
|
return ttmp;
|
||||||
|
if (!stable)
|
||||||
|
return NULL;
|
||||||
|
sk_ASN1_STRING_TABLE_sort(stable);
|
||||||
|
found = sk_ASN1_STRING_TABLE_find(stable, &idx, &fnd);
|
||||||
|
if (!found)
|
||||||
|
return NULL;
|
||||||
|
return sk_ASN1_STRING_TABLE_value(stable, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_STRING_TABLE_add(int nid,
|
||||||
|
long minsize, long maxsize, unsigned long mask,
|
||||||
|
unsigned long flags)
|
||||||
|
{
|
||||||
|
ASN1_STRING_TABLE *tmp;
|
||||||
|
char new_nid = 0;
|
||||||
|
flags &= ~STABLE_FLAGS_MALLOC;
|
||||||
|
if (!stable)
|
||||||
|
stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp);
|
||||||
|
if (!stable) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!(tmp = ASN1_STRING_TABLE_get(nid))) {
|
||||||
|
tmp = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
|
||||||
|
if (!tmp) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
tmp->flags = flags | STABLE_FLAGS_MALLOC;
|
||||||
|
tmp->nid = nid;
|
||||||
|
tmp->minsize = tmp->maxsize = -1;
|
||||||
|
new_nid = 1;
|
||||||
|
} else
|
||||||
|
tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags;
|
||||||
|
if (minsize != -1)
|
||||||
|
tmp->minsize = minsize;
|
||||||
|
if (maxsize != -1)
|
||||||
|
tmp->maxsize = maxsize;
|
||||||
|
tmp->mask = mask;
|
||||||
|
if (new_nid)
|
||||||
|
sk_ASN1_STRING_TABLE_push(stable, tmp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_STRING_TABLE_cleanup(void)
|
||||||
|
{
|
||||||
|
STACK_OF(ASN1_STRING_TABLE) *tmp;
|
||||||
|
tmp = stable;
|
||||||
|
if (!tmp)
|
||||||
|
return;
|
||||||
|
stable = NULL;
|
||||||
|
sk_ASN1_STRING_TABLE_pop_free(tmp, st_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void st_free(ASN1_STRING_TABLE *tbl)
|
||||||
|
{
|
||||||
|
if (tbl->flags & STABLE_FLAGS_MALLOC)
|
||||||
|
OPENSSL_free(tbl);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef STRING_TABLE_TEST
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
ASN1_STRING_TABLE *tmp;
|
||||||
|
int i, last_nid = -1;
|
||||||
|
|
||||||
|
for (tmp = tbl_standard, i = 0;
|
||||||
|
i < sizeof(tbl_standard) / sizeof(ASN1_STRING_TABLE); i++, tmp++) {
|
||||||
|
if (tmp->nid < last_nid) {
|
||||||
|
last_nid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
last_nid = tmp->nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last_nid != 0) {
|
||||||
|
printf("Table order OK\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tmp = tbl_standard, i = 0;
|
||||||
|
i < sizeof(tbl_standard) / sizeof(ASN1_STRING_TABLE); i++, tmp++)
|
||||||
|
printf("Index %d, NID %d, Name=%s\n", i, tmp->nid,
|
||||||
|
OBJ_nid2ln(tmp->nid));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
313
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_strnid.c.grpc_back
generated
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <stdlib.h> /* For bsearch */
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
#include <openssl/obj.h>
|
||||||
|
#include <openssl/stack.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_STRING_TABLE)
|
||||||
|
|
||||||
|
static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
|
||||||
|
static void st_free(ASN1_STRING_TABLE *tbl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the global mask for the mbstring functions: this is use to mask
|
||||||
|
* out certain types (such as BMPString and UTF8String) because certain
|
||||||
|
* software (e.g. Netscape) has problems with them.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static unsigned long global_mask = B_ASN1_UTF8STRING;
|
||||||
|
|
||||||
|
void ASN1_STRING_set_default_mask(unsigned long mask)
|
||||||
|
{
|
||||||
|
global_mask = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long ASN1_STRING_get_default_mask(void)
|
||||||
|
{
|
||||||
|
return global_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function sets the default to various "flavours" of configuration.
|
||||||
|
* based on an ASCII string. Currently this is: MASK:XXXX : a numerical mask
|
||||||
|
* value. nobmp : Don't use BMPStrings (just Printable, T61). pkix : PKIX
|
||||||
|
* recommendation in RFC2459. utf8only : only use UTF8Strings (RFC2459
|
||||||
|
* recommendation for 2004). default: the default value, Printable, T61, BMP.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ASN1_STRING_set_default_mask_asc(const char *p)
|
||||||
|
{
|
||||||
|
unsigned long mask;
|
||||||
|
char *end;
|
||||||
|
if (!strncmp(p, "MASK:", 5)) {
|
||||||
|
if (!p[5])
|
||||||
|
return 0;
|
||||||
|
mask = strtoul(p + 5, &end, 0);
|
||||||
|
if (*end)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcmp(p, "nombstr"))
|
||||||
|
mask = ~((unsigned long)(B_ASN1_BMPSTRING | B_ASN1_UTF8STRING));
|
||||||
|
else if (!strcmp(p, "pkix"))
|
||||||
|
mask = ~((unsigned long)B_ASN1_T61STRING);
|
||||||
|
else if (!strcmp(p, "utf8only"))
|
||||||
|
mask = B_ASN1_UTF8STRING;
|
||||||
|
else if (!strcmp(p, "default"))
|
||||||
|
mask = 0xFFFFFFFFL;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
ASN1_STRING_set_default_mask(mask);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following function generates an ASN1_STRING based on limits in a
|
||||||
|
* table. Frequently the types and length of an ASN1_STRING are restricted by
|
||||||
|
* a corresponding OID. For example certificates and certificate requests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
|
||||||
|
const unsigned char *in, int inlen,
|
||||||
|
int inform, int nid)
|
||||||
|
{
|
||||||
|
ASN1_STRING_TABLE *tbl;
|
||||||
|
ASN1_STRING *str = NULL;
|
||||||
|
unsigned long mask;
|
||||||
|
int ret;
|
||||||
|
if (!out)
|
||||||
|
out = &str;
|
||||||
|
tbl = ASN1_STRING_TABLE_get(nid);
|
||||||
|
if (tbl) {
|
||||||
|
mask = tbl->mask;
|
||||||
|
if (!(tbl->flags & STABLE_NO_MASK))
|
||||||
|
mask &= global_mask;
|
||||||
|
ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask,
|
||||||
|
tbl->minsize, tbl->maxsize);
|
||||||
|
} else
|
||||||
|
ret =
|
||||||
|
ASN1_mbstring_copy(out, in, inlen, inform,
|
||||||
|
DIRSTRING_TYPE & global_mask);
|
||||||
|
if (ret <= 0)
|
||||||
|
return NULL;
|
||||||
|
return *out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now the tables and helper functions for the string table:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* size limits: this stuff is taken straight from RFC3280 */
|
||||||
|
|
||||||
|
#define ub_name 32768
|
||||||
|
#define ub_common_name 64
|
||||||
|
#define ub_locality_name 128
|
||||||
|
#define ub_state_name 128
|
||||||
|
#define ub_organization_name 64
|
||||||
|
#define ub_organization_unit_name 64
|
||||||
|
#define ub_title 64
|
||||||
|
#define ub_email_address 128
|
||||||
|
#define ub_serial_number 64
|
||||||
|
|
||||||
|
/* This table must be kept in NID order */
|
||||||
|
|
||||||
|
static const ASN1_STRING_TABLE tbl_standard[] = {
|
||||||
|
{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||||
|
{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE,
|
||||||
|
0},
|
||||||
|
{NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING,
|
||||||
|
STABLE_NO_MASK},
|
||||||
|
{NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
|
||||||
|
{NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
|
||||||
|
{NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING,
|
||||||
|
STABLE_NO_MASK},
|
||||||
|
{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
|
||||||
|
{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
|
{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||||
|
{NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
|
||||||
|
{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sk_table_cmp(const ASN1_STRING_TABLE **a,
|
||||||
|
const ASN1_STRING_TABLE **b)
|
||||||
|
{
|
||||||
|
return (*a)->nid - (*b)->nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int table_cmp(const void *in_a, const void *in_b)
|
||||||
|
{
|
||||||
|
const ASN1_STRING_TABLE *a = in_a;
|
||||||
|
const ASN1_STRING_TABLE *b = in_b;
|
||||||
|
return a->nid - b->nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||||
|
{
|
||||||
|
int found;
|
||||||
|
size_t idx;
|
||||||
|
ASN1_STRING_TABLE *ttmp;
|
||||||
|
ASN1_STRING_TABLE fnd;
|
||||||
|
fnd.nid = nid;
|
||||||
|
|
||||||
|
ttmp =
|
||||||
|
bsearch(&fnd, tbl_standard,
|
||||||
|
sizeof(tbl_standard) / sizeof(ASN1_STRING_TABLE),
|
||||||
|
sizeof(ASN1_STRING_TABLE), table_cmp);
|
||||||
|
if (ttmp)
|
||||||
|
return ttmp;
|
||||||
|
if (!stable)
|
||||||
|
return NULL;
|
||||||
|
sk_ASN1_STRING_TABLE_sort(stable);
|
||||||
|
found = sk_ASN1_STRING_TABLE_find(stable, &idx, &fnd);
|
||||||
|
if (!found)
|
||||||
|
return NULL;
|
||||||
|
return sk_ASN1_STRING_TABLE_value(stable, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_STRING_TABLE_add(int nid,
|
||||||
|
long minsize, long maxsize, unsigned long mask,
|
||||||
|
unsigned long flags)
|
||||||
|
{
|
||||||
|
ASN1_STRING_TABLE *tmp;
|
||||||
|
char new_nid = 0;
|
||||||
|
flags &= ~STABLE_FLAGS_MALLOC;
|
||||||
|
if (!stable)
|
||||||
|
stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp);
|
||||||
|
if (!stable) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!(tmp = ASN1_STRING_TABLE_get(nid))) {
|
||||||
|
tmp = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
|
||||||
|
if (!tmp) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
tmp->flags = flags | STABLE_FLAGS_MALLOC;
|
||||||
|
tmp->nid = nid;
|
||||||
|
tmp->minsize = tmp->maxsize = -1;
|
||||||
|
new_nid = 1;
|
||||||
|
} else
|
||||||
|
tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags;
|
||||||
|
if (minsize != -1)
|
||||||
|
tmp->minsize = minsize;
|
||||||
|
if (maxsize != -1)
|
||||||
|
tmp->maxsize = maxsize;
|
||||||
|
tmp->mask = mask;
|
||||||
|
if (new_nid)
|
||||||
|
sk_ASN1_STRING_TABLE_push(stable, tmp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_STRING_TABLE_cleanup(void)
|
||||||
|
{
|
||||||
|
STACK_OF(ASN1_STRING_TABLE) *tmp;
|
||||||
|
tmp = stable;
|
||||||
|
if (!tmp)
|
||||||
|
return;
|
||||||
|
stable = NULL;
|
||||||
|
sk_ASN1_STRING_TABLE_pop_free(tmp, st_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void st_free(ASN1_STRING_TABLE *tbl)
|
||||||
|
{
|
||||||
|
if (tbl->flags & STABLE_FLAGS_MALLOC)
|
||||||
|
OPENSSL_free(tbl);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef STRING_TABLE_TEST
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
ASN1_STRING_TABLE *tmp;
|
||||||
|
int i, last_nid = -1;
|
||||||
|
|
||||||
|
for (tmp = tbl_standard, i = 0;
|
||||||
|
i < sizeof(tbl_standard) / sizeof(ASN1_STRING_TABLE); i++, tmp++) {
|
||||||
|
if (tmp->nid < last_nid) {
|
||||||
|
last_nid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
last_nid = tmp->nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last_nid != 0) {
|
||||||
|
printf("Table order OK\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tmp = tbl_standard, i = 0;
|
||||||
|
i < sizeof(tbl_standard) / sizeof(ASN1_STRING_TABLE); i++, tmp++)
|
||||||
|
printf("Index %d, NID %d, Name=%s\n", i, tmp->nid,
|
||||||
|
OBJ_nid2ln(tmp->nid));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
212
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_time.c
generated
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1t.h>
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is an implementation of the ASN1 Time structure which is: Time ::=
|
||||||
|
* CHOICE { utcTime UTCTime, generalTime GeneralizedTime } written by Steve
|
||||||
|
* Henson.
|
||||||
|
*/
|
||||||
|
|
||||||
|
IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
|
||||||
|
|
||||||
|
IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME)
|
||||||
|
|
||||||
|
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
|
||||||
|
{
|
||||||
|
return ASN1_TIME_adj(s, t, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
|
||||||
|
int offset_day, long offset_sec)
|
||||||
|
{
|
||||||
|
struct tm *ts;
|
||||||
|
struct tm data;
|
||||||
|
|
||||||
|
ts = OPENSSL_gmtime(&t, &data);
|
||||||
|
if (ts == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ERROR_GETTING_TIME);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (offset_day || offset_sec) {
|
||||||
|
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if ((ts->tm_year >= 50) && (ts->tm_year < 150))
|
||||||
|
return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec);
|
||||||
|
return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_TIME_check(ASN1_TIME *t)
|
||||||
|
{
|
||||||
|
if (t->type == V_ASN1_GENERALIZEDTIME)
|
||||||
|
return ASN1_GENERALIZEDTIME_check(t);
|
||||||
|
else if (t->type == V_ASN1_UTCTIME)
|
||||||
|
return ASN1_UTCTIME_check(t);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert an ASN1_TIME structure to GeneralizedTime */
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
|
||||||
|
ASN1_GENERALIZEDTIME **out)
|
||||||
|
{
|
||||||
|
ASN1_GENERALIZEDTIME *ret = NULL;
|
||||||
|
char *str;
|
||||||
|
int newlen;
|
||||||
|
|
||||||
|
if (!ASN1_TIME_check(t))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!out || !*out) {
|
||||||
|
if (!(ret = ASN1_GENERALIZEDTIME_new()))
|
||||||
|
goto err;
|
||||||
|
} else {
|
||||||
|
ret = *out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If already GeneralizedTime just copy across */
|
||||||
|
if (t->type == V_ASN1_GENERALIZEDTIME) {
|
||||||
|
if (!ASN1_STRING_set(ret, t->data, t->length))
|
||||||
|
goto err;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* grow the string */
|
||||||
|
if (!ASN1_STRING_set(ret, NULL, t->length + 2))
|
||||||
|
goto err;
|
||||||
|
/* ASN1_STRING_set() allocated 'len + 1' bytes. */
|
||||||
|
newlen = t->length + 2 + 1;
|
||||||
|
str = (char *)ret->data;
|
||||||
|
/* Work out the century and prepend */
|
||||||
|
if (t->data[0] >= '5')
|
||||||
|
OPENSSL_strlcpy(str, "19", newlen);
|
||||||
|
else
|
||||||
|
OPENSSL_strlcpy(str, "20", newlen);
|
||||||
|
|
||||||
|
OPENSSL_strlcat(str, (char *)t->data, newlen);
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (out != NULL && *out == NULL)
|
||||||
|
*out = ret;
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (out == NULL || *out != ret)
|
||||||
|
ASN1_GENERALIZEDTIME_free(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
|
||||||
|
{
|
||||||
|
ASN1_TIME t;
|
||||||
|
|
||||||
|
t.length = strlen(str);
|
||||||
|
t.data = (unsigned char *)str;
|
||||||
|
t.flags = 0;
|
||||||
|
|
||||||
|
t.type = V_ASN1_UTCTIME;
|
||||||
|
|
||||||
|
if (!ASN1_TIME_check(&t)) {
|
||||||
|
t.type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
if (!ASN1_TIME_check(&t))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t)
|
||||||
|
{
|
||||||
|
if (t == NULL) {
|
||||||
|
time_t now_t;
|
||||||
|
time(&now_t);
|
||||||
|
if (OPENSSL_gmtime(&now_t, tm))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t->type == V_ASN1_UTCTIME)
|
||||||
|
return asn1_utctime_to_tm(tm, t);
|
||||||
|
else if (t->type == V_ASN1_GENERALIZEDTIME)
|
||||||
|
return asn1_generalizedtime_to_tm(tm, t);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_TIME_diff(int *pday, int *psec,
|
||||||
|
const ASN1_TIME *from, const ASN1_TIME *to)
|
||||||
|
{
|
||||||
|
struct tm tm_from, tm_to;
|
||||||
|
if (!asn1_time_to_tm(&tm_from, from))
|
||||||
|
return 0;
|
||||||
|
if (!asn1_time_to_tm(&tm_to, to))
|
||||||
|
return 0;
|
||||||
|
return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
|
||||||
|
}
|
||||||
212
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_time.c.grpc_back
generated
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <openssl/asn1t.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is an implementation of the ASN1 Time structure which is: Time ::=
|
||||||
|
* CHOICE { utcTime UTCTime, generalTime GeneralizedTime } written by Steve
|
||||||
|
* Henson.
|
||||||
|
*/
|
||||||
|
|
||||||
|
IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
|
||||||
|
|
||||||
|
IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME)
|
||||||
|
|
||||||
|
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
|
||||||
|
{
|
||||||
|
return ASN1_TIME_adj(s, t, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
|
||||||
|
int offset_day, long offset_sec)
|
||||||
|
{
|
||||||
|
struct tm *ts;
|
||||||
|
struct tm data;
|
||||||
|
|
||||||
|
ts = OPENSSL_gmtime(&t, &data);
|
||||||
|
if (ts == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ERROR_GETTING_TIME);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (offset_day || offset_sec) {
|
||||||
|
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if ((ts->tm_year >= 50) && (ts->tm_year < 150))
|
||||||
|
return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec);
|
||||||
|
return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_TIME_check(ASN1_TIME *t)
|
||||||
|
{
|
||||||
|
if (t->type == V_ASN1_GENERALIZEDTIME)
|
||||||
|
return ASN1_GENERALIZEDTIME_check(t);
|
||||||
|
else if (t->type == V_ASN1_UTCTIME)
|
||||||
|
return ASN1_UTCTIME_check(t);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert an ASN1_TIME structure to GeneralizedTime */
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
|
||||||
|
ASN1_GENERALIZEDTIME **out)
|
||||||
|
{
|
||||||
|
ASN1_GENERALIZEDTIME *ret = NULL;
|
||||||
|
char *str;
|
||||||
|
int newlen;
|
||||||
|
|
||||||
|
if (!ASN1_TIME_check(t))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!out || !*out) {
|
||||||
|
if (!(ret = ASN1_GENERALIZEDTIME_new()))
|
||||||
|
goto err;
|
||||||
|
} else {
|
||||||
|
ret = *out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If already GeneralizedTime just copy across */
|
||||||
|
if (t->type == V_ASN1_GENERALIZEDTIME) {
|
||||||
|
if (!ASN1_STRING_set(ret, t->data, t->length))
|
||||||
|
goto err;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* grow the string */
|
||||||
|
if (!ASN1_STRING_set(ret, NULL, t->length + 2))
|
||||||
|
goto err;
|
||||||
|
/* ASN1_STRING_set() allocated 'len + 1' bytes. */
|
||||||
|
newlen = t->length + 2 + 1;
|
||||||
|
str = (char *)ret->data;
|
||||||
|
/* Work out the century and prepend */
|
||||||
|
if (t->data[0] >= '5')
|
||||||
|
OPENSSL_strlcpy(str, "19", newlen);
|
||||||
|
else
|
||||||
|
OPENSSL_strlcpy(str, "20", newlen);
|
||||||
|
|
||||||
|
OPENSSL_strlcat(str, (char *)t->data, newlen);
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (out != NULL && *out == NULL)
|
||||||
|
*out = ret;
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (out == NULL || *out != ret)
|
||||||
|
ASN1_GENERALIZEDTIME_free(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
|
||||||
|
{
|
||||||
|
ASN1_TIME t;
|
||||||
|
|
||||||
|
t.length = strlen(str);
|
||||||
|
t.data = (unsigned char *)str;
|
||||||
|
t.flags = 0;
|
||||||
|
|
||||||
|
t.type = V_ASN1_UTCTIME;
|
||||||
|
|
||||||
|
if (!ASN1_TIME_check(&t)) {
|
||||||
|
t.type = V_ASN1_GENERALIZEDTIME;
|
||||||
|
if (!ASN1_TIME_check(&t))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t)
|
||||||
|
{
|
||||||
|
if (t == NULL) {
|
||||||
|
time_t now_t;
|
||||||
|
time(&now_t);
|
||||||
|
if (OPENSSL_gmtime(&now_t, tm))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t->type == V_ASN1_UTCTIME)
|
||||||
|
return asn1_utctime_to_tm(tm, t);
|
||||||
|
else if (t->type == V_ASN1_GENERALIZEDTIME)
|
||||||
|
return asn1_generalizedtime_to_tm(tm, t);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_TIME_diff(int *pday, int *psec,
|
||||||
|
const ASN1_TIME *from, const ASN1_TIME *to)
|
||||||
|
{
|
||||||
|
struct tm tm_from, tm_to;
|
||||||
|
if (!asn1_time_to_tm(&tm_from, from))
|
||||||
|
return 0;
|
||||||
|
if (!asn1_time_to_tm(&tm_to, to))
|
||||||
|
return 0;
|
||||||
|
return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
|
||||||
|
}
|
||||||
151
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_type.c
generated
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1t.h>
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
#include <openssl_grpc/obj.h>
|
||||||
|
|
||||||
|
int ASN1_TYPE_get(ASN1_TYPE *a)
|
||||||
|
{
|
||||||
|
if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
|
||||||
|
return (a->type);
|
||||||
|
else
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
|
||||||
|
{
|
||||||
|
if (a->value.ptr != NULL) {
|
||||||
|
ASN1_TYPE **tmp_a = &a;
|
||||||
|
ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL);
|
||||||
|
}
|
||||||
|
a->type = type;
|
||||||
|
if (type == V_ASN1_BOOLEAN)
|
||||||
|
a->value.boolean = value ? 0xff : 0;
|
||||||
|
else
|
||||||
|
a->value.ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)
|
||||||
|
{
|
||||||
|
if (!value || (type == V_ASN1_BOOLEAN)) {
|
||||||
|
void *p = (void *)value;
|
||||||
|
ASN1_TYPE_set(a, type, p);
|
||||||
|
} else if (type == V_ASN1_OBJECT) {
|
||||||
|
ASN1_OBJECT *odup;
|
||||||
|
odup = OBJ_dup(value);
|
||||||
|
if (!odup)
|
||||||
|
return 0;
|
||||||
|
ASN1_TYPE_set(a, type, odup);
|
||||||
|
} else {
|
||||||
|
ASN1_STRING *sdup;
|
||||||
|
sdup = ASN1_STRING_dup(value);
|
||||||
|
if (!sdup)
|
||||||
|
return 0;
|
||||||
|
ASN1_TYPE_set(a, type, sdup);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns 0 if they are equal, != 0 otherwise. */
|
||||||
|
int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
|
||||||
|
{
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
if (!a || !b || a->type != b->type)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch (a->type) {
|
||||||
|
case V_ASN1_OBJECT:
|
||||||
|
result = OBJ_cmp(a->value.object, b->value.object);
|
||||||
|
break;
|
||||||
|
case V_ASN1_NULL:
|
||||||
|
result = 0; /* They do not have content. */
|
||||||
|
break;
|
||||||
|
case V_ASN1_BOOLEAN:
|
||||||
|
result = a->value.boolean - b->value.boolean;
|
||||||
|
break;
|
||||||
|
case V_ASN1_INTEGER:
|
||||||
|
case V_ASN1_ENUMERATED:
|
||||||
|
case V_ASN1_BIT_STRING:
|
||||||
|
case V_ASN1_OCTET_STRING:
|
||||||
|
case V_ASN1_SEQUENCE:
|
||||||
|
case V_ASN1_SET:
|
||||||
|
case V_ASN1_NUMERICSTRING:
|
||||||
|
case V_ASN1_PRINTABLESTRING:
|
||||||
|
case V_ASN1_T61STRING:
|
||||||
|
case V_ASN1_VIDEOTEXSTRING:
|
||||||
|
case V_ASN1_IA5STRING:
|
||||||
|
case V_ASN1_UTCTIME:
|
||||||
|
case V_ASN1_GENERALIZEDTIME:
|
||||||
|
case V_ASN1_GRAPHICSTRING:
|
||||||
|
case V_ASN1_VISIBLESTRING:
|
||||||
|
case V_ASN1_GENERALSTRING:
|
||||||
|
case V_ASN1_UNIVERSALSTRING:
|
||||||
|
case V_ASN1_BMPSTRING:
|
||||||
|
case V_ASN1_UTF8STRING:
|
||||||
|
case V_ASN1_OTHER:
|
||||||
|
default:
|
||||||
|
result = ASN1_STRING_cmp((ASN1_STRING *)a->value.ptr,
|
||||||
|
(ASN1_STRING *)b->value.ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
151
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_type.c.grpc_back
generated
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl/asn1t.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
#include <openssl/obj.h>
|
||||||
|
|
||||||
|
int ASN1_TYPE_get(ASN1_TYPE *a)
|
||||||
|
{
|
||||||
|
if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
|
||||||
|
return (a->type);
|
||||||
|
else
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
|
||||||
|
{
|
||||||
|
if (a->value.ptr != NULL) {
|
||||||
|
ASN1_TYPE **tmp_a = &a;
|
||||||
|
ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL);
|
||||||
|
}
|
||||||
|
a->type = type;
|
||||||
|
if (type == V_ASN1_BOOLEAN)
|
||||||
|
a->value.boolean = value ? 0xff : 0;
|
||||||
|
else
|
||||||
|
a->value.ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)
|
||||||
|
{
|
||||||
|
if (!value || (type == V_ASN1_BOOLEAN)) {
|
||||||
|
void *p = (void *)value;
|
||||||
|
ASN1_TYPE_set(a, type, p);
|
||||||
|
} else if (type == V_ASN1_OBJECT) {
|
||||||
|
ASN1_OBJECT *odup;
|
||||||
|
odup = OBJ_dup(value);
|
||||||
|
if (!odup)
|
||||||
|
return 0;
|
||||||
|
ASN1_TYPE_set(a, type, odup);
|
||||||
|
} else {
|
||||||
|
ASN1_STRING *sdup;
|
||||||
|
sdup = ASN1_STRING_dup(value);
|
||||||
|
if (!sdup)
|
||||||
|
return 0;
|
||||||
|
ASN1_TYPE_set(a, type, sdup);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns 0 if they are equal, != 0 otherwise. */
|
||||||
|
int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
|
||||||
|
{
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
if (!a || !b || a->type != b->type)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch (a->type) {
|
||||||
|
case V_ASN1_OBJECT:
|
||||||
|
result = OBJ_cmp(a->value.object, b->value.object);
|
||||||
|
break;
|
||||||
|
case V_ASN1_NULL:
|
||||||
|
result = 0; /* They do not have content. */
|
||||||
|
break;
|
||||||
|
case V_ASN1_BOOLEAN:
|
||||||
|
result = a->value.boolean - b->value.boolean;
|
||||||
|
break;
|
||||||
|
case V_ASN1_INTEGER:
|
||||||
|
case V_ASN1_ENUMERATED:
|
||||||
|
case V_ASN1_BIT_STRING:
|
||||||
|
case V_ASN1_OCTET_STRING:
|
||||||
|
case V_ASN1_SEQUENCE:
|
||||||
|
case V_ASN1_SET:
|
||||||
|
case V_ASN1_NUMERICSTRING:
|
||||||
|
case V_ASN1_PRINTABLESTRING:
|
||||||
|
case V_ASN1_T61STRING:
|
||||||
|
case V_ASN1_VIDEOTEXSTRING:
|
||||||
|
case V_ASN1_IA5STRING:
|
||||||
|
case V_ASN1_UTCTIME:
|
||||||
|
case V_ASN1_GENERALIZEDTIME:
|
||||||
|
case V_ASN1_GRAPHICSTRING:
|
||||||
|
case V_ASN1_VISIBLESTRING:
|
||||||
|
case V_ASN1_GENERALSTRING:
|
||||||
|
case V_ASN1_UNIVERSALSTRING:
|
||||||
|
case V_ASN1_BMPSTRING:
|
||||||
|
case V_ASN1_UTF8STRING:
|
||||||
|
case V_ASN1_OTHER:
|
||||||
|
default:
|
||||||
|
result = ASN1_STRING_cmp((ASN1_STRING *)a->value.ptr,
|
||||||
|
(ASN1_STRING *)b->value.ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
303
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_utctm.c
generated
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
|
||||||
|
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
|
||||||
|
{
|
||||||
|
static const int min[8] = { 0, 1, 1, 0, 0, 0, 0, 0 };
|
||||||
|
static const int max[8] = { 99, 12, 31, 23, 59, 59, 12, 59 };
|
||||||
|
char *a;
|
||||||
|
int n, i, l, o;
|
||||||
|
|
||||||
|
if (d->type != V_ASN1_UTCTIME)
|
||||||
|
return (0);
|
||||||
|
l = d->length;
|
||||||
|
a = (char *)d->data;
|
||||||
|
o = 0;
|
||||||
|
|
||||||
|
if (l < 11)
|
||||||
|
goto err;
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
if ((i == 5) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||||
|
i++;
|
||||||
|
if (tm)
|
||||||
|
tm->tm_sec = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
tm->tm_year = n < 50 ? n + 100 : n;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
tm->tm_mon = n - 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
tm->tm_mday = n;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
tm->tm_hour = n;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
tm->tm_min = n;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
tm->tm_sec = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (a[o] == 'Z')
|
||||||
|
o++;
|
||||||
|
else if ((a[o] == '+') || (a[o] == '-')) {
|
||||||
|
int offsign = a[o] == '-' ? 1 : -1, offset = 0;
|
||||||
|
o++;
|
||||||
|
if (o + 4 > l)
|
||||||
|
goto err;
|
||||||
|
for (i = 6; i < 8; i++) {
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
o++;
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
if (i == 6)
|
||||||
|
offset = n * 3600;
|
||||||
|
else if (i == 7)
|
||||||
|
offset += n * 60;
|
||||||
|
}
|
||||||
|
o++;
|
||||||
|
}
|
||||||
|
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return o == l;
|
||||||
|
err:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
|
||||||
|
{
|
||||||
|
return asn1_utctime_to_tm(NULL, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
|
||||||
|
{
|
||||||
|
ASN1_UTCTIME t;
|
||||||
|
|
||||||
|
t.type = V_ASN1_UTCTIME;
|
||||||
|
t.length = strlen(str);
|
||||||
|
t.data = (unsigned char *)str;
|
||||||
|
if (ASN1_UTCTIME_check(&t)) {
|
||||||
|
if (s != NULL) {
|
||||||
|
if (!ASN1_STRING_set((ASN1_STRING *)s,
|
||||||
|
(unsigned char *)str, t.length))
|
||||||
|
return 0;
|
||||||
|
s->type = V_ASN1_UTCTIME;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
} else
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||||
|
{
|
||||||
|
return ASN1_UTCTIME_adj(s, t, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
|
||||||
|
int offset_day, long offset_sec)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
struct tm *ts;
|
||||||
|
struct tm data;
|
||||||
|
size_t len = 20;
|
||||||
|
int free_s = 0;
|
||||||
|
|
||||||
|
if (s == NULL) {
|
||||||
|
free_s = 1;
|
||||||
|
s = M_ASN1_UTCTIME_new();
|
||||||
|
}
|
||||||
|
if (s == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
ts = OPENSSL_gmtime(&t, &data);
|
||||||
|
if (ts == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (offset_day || offset_sec) {
|
||||||
|
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ts->tm_year < 50) || (ts->tm_year >= 150))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
p = (char *)s->data;
|
||||||
|
if ((p == NULL) || ((size_t)s->length < len)) {
|
||||||
|
p = OPENSSL_malloc(len);
|
||||||
|
if (p == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (s->data != NULL)
|
||||||
|
OPENSSL_free(s->data);
|
||||||
|
s->data = (unsigned char *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100,
|
||||||
|
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||||
|
ts->tm_sec);
|
||||||
|
s->length = strlen(p);
|
||||||
|
s->type = V_ASN1_UTCTIME;
|
||||||
|
return (s);
|
||||||
|
err:
|
||||||
|
if (free_s && s)
|
||||||
|
M_ASN1_UTCTIME_free(s);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
|
||||||
|
{
|
||||||
|
struct tm stm, ttm;
|
||||||
|
int day, sec;
|
||||||
|
|
||||||
|
if (!asn1_utctime_to_tm(&stm, s))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (!OPENSSL_gmtime(&t, &ttm))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (day > 0)
|
||||||
|
return 1;
|
||||||
|
if (day < 0)
|
||||||
|
return -1;
|
||||||
|
if (sec > 0)
|
||||||
|
return 1;
|
||||||
|
if (sec < 0)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s)
|
||||||
|
{
|
||||||
|
struct tm tm;
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
OPENSSL_memset(&tm, '\0', sizeof tm);
|
||||||
|
|
||||||
|
# define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
|
||||||
|
tm.tm_year = g2(s->data);
|
||||||
|
if (tm.tm_year < 50)
|
||||||
|
tm.tm_year += 100;
|
||||||
|
tm.tm_mon = g2(s->data + 2) - 1;
|
||||||
|
tm.tm_mday = g2(s->data + 4);
|
||||||
|
tm.tm_hour = g2(s->data + 6);
|
||||||
|
tm.tm_min = g2(s->data + 8);
|
||||||
|
tm.tm_sec = g2(s->data + 10);
|
||||||
|
if (s->data[12] == 'Z')
|
||||||
|
offset = 0;
|
||||||
|
else {
|
||||||
|
offset = g2(s->data + 13) * 60 + g2(s->data + 15);
|
||||||
|
if (s->data[12] == '-')
|
||||||
|
offset = -offset;
|
||||||
|
}
|
||||||
|
# undef g2
|
||||||
|
|
||||||
|
return mktime(&tm) - offset * 60; /* FIXME: mktime assumes the current
|
||||||
|
* timezone instead of UTC, and unless
|
||||||
|
* we rewrite OpenSSL in Lisp we cannot
|
||||||
|
* locally change the timezone without
|
||||||
|
* possibly interfering with other
|
||||||
|
* parts of the program. timegm, which
|
||||||
|
* uses UTC, is non-standard. Also
|
||||||
|
* time_t is inappropriate for general
|
||||||
|
* UTC times because it may a 32 bit
|
||||||
|
* type. */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
303
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_utctm.c.grpc_back
generated
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
|
||||||
|
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
|
||||||
|
{
|
||||||
|
static const int min[8] = { 0, 1, 1, 0, 0, 0, 0, 0 };
|
||||||
|
static const int max[8] = { 99, 12, 31, 23, 59, 59, 12, 59 };
|
||||||
|
char *a;
|
||||||
|
int n, i, l, o;
|
||||||
|
|
||||||
|
if (d->type != V_ASN1_UTCTIME)
|
||||||
|
return (0);
|
||||||
|
l = d->length;
|
||||||
|
a = (char *)d->data;
|
||||||
|
o = 0;
|
||||||
|
|
||||||
|
if (l < 11)
|
||||||
|
goto err;
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
if ((i == 5) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||||
|
i++;
|
||||||
|
if (tm)
|
||||||
|
tm->tm_sec = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if (++o > l)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
tm->tm_year = n < 50 ? n + 100 : n;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
tm->tm_mon = n - 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
tm->tm_mday = n;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
tm->tm_hour = n;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
tm->tm_min = n;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
tm->tm_sec = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (a[o] == 'Z')
|
||||||
|
o++;
|
||||||
|
else if ((a[o] == '+') || (a[o] == '-')) {
|
||||||
|
int offsign = a[o] == '-' ? 1 : -1, offset = 0;
|
||||||
|
o++;
|
||||||
|
if (o + 4 > l)
|
||||||
|
goto err;
|
||||||
|
for (i = 6; i < 8; i++) {
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = a[o] - '0';
|
||||||
|
o++;
|
||||||
|
if ((a[o] < '0') || (a[o] > '9'))
|
||||||
|
goto err;
|
||||||
|
n = (n * 10) + a[o] - '0';
|
||||||
|
if ((n < min[i]) || (n > max[i]))
|
||||||
|
goto err;
|
||||||
|
if (tm) {
|
||||||
|
if (i == 6)
|
||||||
|
offset = n * 3600;
|
||||||
|
else if (i == 7)
|
||||||
|
offset += n * 60;
|
||||||
|
}
|
||||||
|
o++;
|
||||||
|
}
|
||||||
|
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return o == l;
|
||||||
|
err:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
|
||||||
|
{
|
||||||
|
return asn1_utctime_to_tm(NULL, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
|
||||||
|
{
|
||||||
|
ASN1_UTCTIME t;
|
||||||
|
|
||||||
|
t.type = V_ASN1_UTCTIME;
|
||||||
|
t.length = strlen(str);
|
||||||
|
t.data = (unsigned char *)str;
|
||||||
|
if (ASN1_UTCTIME_check(&t)) {
|
||||||
|
if (s != NULL) {
|
||||||
|
if (!ASN1_STRING_set((ASN1_STRING *)s,
|
||||||
|
(unsigned char *)str, t.length))
|
||||||
|
return 0;
|
||||||
|
s->type = V_ASN1_UTCTIME;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
} else
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||||
|
{
|
||||||
|
return ASN1_UTCTIME_adj(s, t, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
|
||||||
|
int offset_day, long offset_sec)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
struct tm *ts;
|
||||||
|
struct tm data;
|
||||||
|
size_t len = 20;
|
||||||
|
int free_s = 0;
|
||||||
|
|
||||||
|
if (s == NULL) {
|
||||||
|
free_s = 1;
|
||||||
|
s = M_ASN1_UTCTIME_new();
|
||||||
|
}
|
||||||
|
if (s == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
ts = OPENSSL_gmtime(&t, &data);
|
||||||
|
if (ts == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (offset_day || offset_sec) {
|
||||||
|
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ts->tm_year < 50) || (ts->tm_year >= 150))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
p = (char *)s->data;
|
||||||
|
if ((p == NULL) || ((size_t)s->length < len)) {
|
||||||
|
p = OPENSSL_malloc(len);
|
||||||
|
if (p == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (s->data != NULL)
|
||||||
|
OPENSSL_free(s->data);
|
||||||
|
s->data = (unsigned char *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100,
|
||||||
|
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||||
|
ts->tm_sec);
|
||||||
|
s->length = strlen(p);
|
||||||
|
s->type = V_ASN1_UTCTIME;
|
||||||
|
return (s);
|
||||||
|
err:
|
||||||
|
if (free_s && s)
|
||||||
|
M_ASN1_UTCTIME_free(s);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
|
||||||
|
{
|
||||||
|
struct tm stm, ttm;
|
||||||
|
int day, sec;
|
||||||
|
|
||||||
|
if (!asn1_utctime_to_tm(&stm, s))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (!OPENSSL_gmtime(&t, &ttm))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (day > 0)
|
||||||
|
return 1;
|
||||||
|
if (day < 0)
|
||||||
|
return -1;
|
||||||
|
if (sec > 0)
|
||||||
|
return 1;
|
||||||
|
if (sec < 0)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s)
|
||||||
|
{
|
||||||
|
struct tm tm;
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
OPENSSL_memset(&tm, '\0', sizeof tm);
|
||||||
|
|
||||||
|
# define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
|
||||||
|
tm.tm_year = g2(s->data);
|
||||||
|
if (tm.tm_year < 50)
|
||||||
|
tm.tm_year += 100;
|
||||||
|
tm.tm_mon = g2(s->data + 2) - 1;
|
||||||
|
tm.tm_mday = g2(s->data + 4);
|
||||||
|
tm.tm_hour = g2(s->data + 6);
|
||||||
|
tm.tm_min = g2(s->data + 8);
|
||||||
|
tm.tm_sec = g2(s->data + 10);
|
||||||
|
if (s->data[12] == 'Z')
|
||||||
|
offset = 0;
|
||||||
|
else {
|
||||||
|
offset = g2(s->data + 13) * 60 + g2(s->data + 15);
|
||||||
|
if (s->data[12] == '-')
|
||||||
|
offset = -offset;
|
||||||
|
}
|
||||||
|
# undef g2
|
||||||
|
|
||||||
|
return mktime(&tm) - offset * 60; /* FIXME: mktime assumes the current
|
||||||
|
* timezone instead of UTC, and unless
|
||||||
|
* we rewrite OpenSSL in Lisp we cannot
|
||||||
|
* locally change the timezone without
|
||||||
|
* possibly interfering with other
|
||||||
|
* parts of the program. timegm, which
|
||||||
|
* uses UTC, is non-standard. Also
|
||||||
|
* time_t is inappropriate for general
|
||||||
|
* UTC times because it may a 32 bit
|
||||||
|
* type. */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
236
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_utf8.c
generated
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
/* UTF8 utilities */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This parses a UTF8 string one character at a time. It is passed a pointer
|
||||||
|
* to the string and the length of the string. It sets 'value' to the value
|
||||||
|
* of the current character. It returns the number of characters read or a
|
||||||
|
* negative error code: -1 = string too short -2 = illegal character -3 =
|
||||||
|
* subsequent characters not of the form 10xxxxxx -4 = character encoded
|
||||||
|
* incorrectly (not minimal length).
|
||||||
|
*/
|
||||||
|
|
||||||
|
int UTF8_getc(const unsigned char *str, int len, uint32_t *val)
|
||||||
|
{
|
||||||
|
const unsigned char *p;
|
||||||
|
uint32_t value;
|
||||||
|
int ret;
|
||||||
|
if (len <= 0)
|
||||||
|
return 0;
|
||||||
|
p = str;
|
||||||
|
|
||||||
|
/* Check syntax and work out the encoded value (if correct) */
|
||||||
|
if ((*p & 0x80) == 0) {
|
||||||
|
value = *p++ & 0x7f;
|
||||||
|
ret = 1;
|
||||||
|
} else if ((*p & 0xe0) == 0xc0) {
|
||||||
|
if (len < 2)
|
||||||
|
return -1;
|
||||||
|
if ((p[1] & 0xc0) != 0x80)
|
||||||
|
return -3;
|
||||||
|
value = (*p++ & 0x1f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x80)
|
||||||
|
return -4;
|
||||||
|
ret = 2;
|
||||||
|
} else if ((*p & 0xf0) == 0xe0) {
|
||||||
|
if (len < 3)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = (*p++ & 0xf) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x800)
|
||||||
|
return -4;
|
||||||
|
ret = 3;
|
||||||
|
} else if ((*p & 0xf8) == 0xf0) {
|
||||||
|
if (len < 4)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80)
|
||||||
|
|| ((p[3] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = ((uint32_t)(*p++ & 0x7)) << 18;
|
||||||
|
value |= (*p++ & 0x3f) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x10000)
|
||||||
|
return -4;
|
||||||
|
ret = 4;
|
||||||
|
} else if ((*p & 0xfc) == 0xf8) {
|
||||||
|
if (len < 5)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80)
|
||||||
|
|| ((p[3] & 0xc0) != 0x80)
|
||||||
|
|| ((p[4] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = ((uint32_t)(*p++ & 0x3)) << 24;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 18;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x200000)
|
||||||
|
return -4;
|
||||||
|
ret = 5;
|
||||||
|
} else if ((*p & 0xfe) == 0xfc) {
|
||||||
|
if (len < 6)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80)
|
||||||
|
|| ((p[3] & 0xc0) != 0x80)
|
||||||
|
|| ((p[4] & 0xc0) != 0x80)
|
||||||
|
|| ((p[5] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = ((uint32_t)(*p++ & 0x1)) << 30;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 24;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 18;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x4000000)
|
||||||
|
return -4;
|
||||||
|
ret = 6;
|
||||||
|
} else
|
||||||
|
return -2;
|
||||||
|
*val = value;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This takes a character 'value' and writes the UTF8 encoded value in 'str'
|
||||||
|
* where 'str' is a buffer containing 'len' characters. Returns the number of
|
||||||
|
* characters written or -1 if 'len' is too small. 'str' can be set to NULL
|
||||||
|
* in which case it just returns the number of characters. It will need at
|
||||||
|
* most 6 characters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int UTF8_putc(unsigned char *str, int len, uint32_t value)
|
||||||
|
{
|
||||||
|
if (!str)
|
||||||
|
len = 6; /* Maximum we will need */
|
||||||
|
else if (len <= 0)
|
||||||
|
return -1;
|
||||||
|
if (value < 0x80) {
|
||||||
|
if (str)
|
||||||
|
*str = (unsigned char)value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (value < 0x800) {
|
||||||
|
if (len < 2)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x1f) | 0xc0);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (value < 0x10000) {
|
||||||
|
if (len < 3)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0xf) | 0xe0);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (value < 0x200000) {
|
||||||
|
if (len < 4)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 18) & 0x7) | 0xf0);
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
if (value < 0x4000000) {
|
||||||
|
if (len < 5)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 24) & 0x3) | 0xf8);
|
||||||
|
*str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
if (len < 6)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 30) & 0x1) | 0xfc);
|
||||||
|
*str++ = (unsigned char)(((value >> 24) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
236
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/a_utf8.c.grpc_back
generated
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl/asn1.h>
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/mem.h>
|
||||||
|
|
||||||
|
#include "asn1_locl.h"
|
||||||
|
|
||||||
|
/* UTF8 utilities */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This parses a UTF8 string one character at a time. It is passed a pointer
|
||||||
|
* to the string and the length of the string. It sets 'value' to the value
|
||||||
|
* of the current character. It returns the number of characters read or a
|
||||||
|
* negative error code: -1 = string too short -2 = illegal character -3 =
|
||||||
|
* subsequent characters not of the form 10xxxxxx -4 = character encoded
|
||||||
|
* incorrectly (not minimal length).
|
||||||
|
*/
|
||||||
|
|
||||||
|
int UTF8_getc(const unsigned char *str, int len, uint32_t *val)
|
||||||
|
{
|
||||||
|
const unsigned char *p;
|
||||||
|
uint32_t value;
|
||||||
|
int ret;
|
||||||
|
if (len <= 0)
|
||||||
|
return 0;
|
||||||
|
p = str;
|
||||||
|
|
||||||
|
/* Check syntax and work out the encoded value (if correct) */
|
||||||
|
if ((*p & 0x80) == 0) {
|
||||||
|
value = *p++ & 0x7f;
|
||||||
|
ret = 1;
|
||||||
|
} else if ((*p & 0xe0) == 0xc0) {
|
||||||
|
if (len < 2)
|
||||||
|
return -1;
|
||||||
|
if ((p[1] & 0xc0) != 0x80)
|
||||||
|
return -3;
|
||||||
|
value = (*p++ & 0x1f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x80)
|
||||||
|
return -4;
|
||||||
|
ret = 2;
|
||||||
|
} else if ((*p & 0xf0) == 0xe0) {
|
||||||
|
if (len < 3)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = (*p++ & 0xf) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x800)
|
||||||
|
return -4;
|
||||||
|
ret = 3;
|
||||||
|
} else if ((*p & 0xf8) == 0xf0) {
|
||||||
|
if (len < 4)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80)
|
||||||
|
|| ((p[3] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = ((uint32_t)(*p++ & 0x7)) << 18;
|
||||||
|
value |= (*p++ & 0x3f) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x10000)
|
||||||
|
return -4;
|
||||||
|
ret = 4;
|
||||||
|
} else if ((*p & 0xfc) == 0xf8) {
|
||||||
|
if (len < 5)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80)
|
||||||
|
|| ((p[3] & 0xc0) != 0x80)
|
||||||
|
|| ((p[4] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = ((uint32_t)(*p++ & 0x3)) << 24;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 18;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x200000)
|
||||||
|
return -4;
|
||||||
|
ret = 5;
|
||||||
|
} else if ((*p & 0xfe) == 0xfc) {
|
||||||
|
if (len < 6)
|
||||||
|
return -1;
|
||||||
|
if (((p[1] & 0xc0) != 0x80)
|
||||||
|
|| ((p[2] & 0xc0) != 0x80)
|
||||||
|
|| ((p[3] & 0xc0) != 0x80)
|
||||||
|
|| ((p[4] & 0xc0) != 0x80)
|
||||||
|
|| ((p[5] & 0xc0) != 0x80))
|
||||||
|
return -3;
|
||||||
|
value = ((uint32_t)(*p++ & 0x1)) << 30;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 24;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 18;
|
||||||
|
value |= ((uint32_t)(*p++ & 0x3f)) << 12;
|
||||||
|
value |= (*p++ & 0x3f) << 6;
|
||||||
|
value |= *p++ & 0x3f;
|
||||||
|
if (value < 0x4000000)
|
||||||
|
return -4;
|
||||||
|
ret = 6;
|
||||||
|
} else
|
||||||
|
return -2;
|
||||||
|
*val = value;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This takes a character 'value' and writes the UTF8 encoded value in 'str'
|
||||||
|
* where 'str' is a buffer containing 'len' characters. Returns the number of
|
||||||
|
* characters written or -1 if 'len' is too small. 'str' can be set to NULL
|
||||||
|
* in which case it just returns the number of characters. It will need at
|
||||||
|
* most 6 characters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int UTF8_putc(unsigned char *str, int len, uint32_t value)
|
||||||
|
{
|
||||||
|
if (!str)
|
||||||
|
len = 6; /* Maximum we will need */
|
||||||
|
else if (len <= 0)
|
||||||
|
return -1;
|
||||||
|
if (value < 0x80) {
|
||||||
|
if (str)
|
||||||
|
*str = (unsigned char)value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (value < 0x800) {
|
||||||
|
if (len < 2)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x1f) | 0xc0);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (value < 0x10000) {
|
||||||
|
if (len < 3)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0xf) | 0xe0);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (value < 0x200000) {
|
||||||
|
if (len < 4)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 18) & 0x7) | 0xf0);
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
if (value < 0x4000000) {
|
||||||
|
if (len < 5)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 24) & 0x3) | 0xf8);
|
||||||
|
*str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
if (len < 6)
|
||||||
|
return -1;
|
||||||
|
if (str) {
|
||||||
|
*str++ = (unsigned char)(((value >> 30) & 0x1) | 0xfc);
|
||||||
|
*str++ = (unsigned char)(((value >> 24) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
|
||||||
|
*str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
|
||||||
|
*str = (unsigned char)((value & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
446
IoT-iOS/Pods/BoringSSL-GRPC/src/crypto/asn1/asn1_lib.c
generated
Normal file
@ -0,0 +1,446 @@
|
|||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This package is an SSL implementation written
|
||||||
|
* by Eric Young (eay@cryptsoft.com).
|
||||||
|
* The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
*
|
||||||
|
* This library is free for commercial and non-commercial use as long as
|
||||||
|
* the following conditions are aheared to. The following conditions
|
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
* included with this distribution is covered by the same copyright terms
|
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
*
|
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
* the code are not to be removed.
|
||||||
|
* If this package is used in a product, Eric Young should be given attribution
|
||||||
|
* as the author of the parts of the library used.
|
||||||
|
* This can be in the form of a textual message at program startup or
|
||||||
|
* in documentation (online or textual) provided with the package.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* "This product includes cryptographic software written by
|
||||||
|
* Eric Young (eay@cryptsoft.com)"
|
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
* being used are not cryptographic related :-).
|
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
* the apps directory (application code) you must include an acknowledgement:
|
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The licence and distribution terms for any publically available version or
|
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
* copied and put under another distribution licence
|
||||||
|
* [including the GNU Public Licence.] */
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <openssl_grpc/asn1_mac.h>
|
||||||
|
#include <openssl_grpc/err.h>
|
||||||
|
#include <openssl_grpc/mem.h>
|
||||||
|
|
||||||
|
#include "../internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Cross-module errors from crypto/x509/i2d_pr.c. */
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNSUPPORTED_PUBLIC_KEY_TYPE)
|
||||||
|
|
||||||
|
/* Cross-module errors from crypto/x509/algorithm.c. */
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, CONTEXT_NOT_INITIALISED)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, DIGEST_AND_KEY_TYPE_NOT_SUPPORTED)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNKNOWN_MESSAGE_DIGEST_ALGORITHM)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNKNOWN_SIGNATURE_ALGORITHM)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, WRONG_PUBLIC_KEY_TYPE)
|
||||||
|
/*
|
||||||
|
* Cross-module errors from crypto/x509/asn1_gen.c. TODO(davidben): Remove
|
||||||
|
* these once asn1_gen.c is gone.
|
||||||
|
*/
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, DEPTH_EXCEEDED)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_BITSTRING_FORMAT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_BOOLEAN)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_FORMAT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_HEX)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_IMPLICIT_TAG)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_INTEGER)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_NESTED_TAGGING)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_NULL_VALUE)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_OBJECT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, ILLEGAL_TIME_VALUE)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INTEGER_NOT_ASCII_FORMAT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_MODIFIER)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_NUMBER)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, LIST_ERROR)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, MISSING_VALUE)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, NOT_ASCII_FORMAT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, OBJECT_NOT_ASCII_FORMAT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, SEQUENCE_OR_SET_NEEDS_CONFIG)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, TIME_NOT_ASCII_FORMAT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNKNOWN_FORMAT)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNKNOWN_TAG)
|
||||||
|
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNSUPPORTED_TYPE)
|
||||||
|
|
||||||
|
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
|
||||||
|
long max);
|
||||||
|
static void asn1_put_length(unsigned char **pp, int length);
|
||||||
|
|
||||||
|
int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
|
||||||
|
int *pclass, long omax)
|
||||||
|
{
|
||||||
|
int i, ret;
|
||||||
|
long l;
|
||||||
|
const unsigned char *p = *pp;
|
||||||
|
int tag, xclass, inf;
|
||||||
|
long max = omax;
|
||||||
|
|
||||||
|
if (!max)
|
||||||
|
goto err;
|
||||||
|
ret = (*p & V_ASN1_CONSTRUCTED);
|
||||||
|
xclass = (*p & V_ASN1_PRIVATE);
|
||||||
|
i = *p & V_ASN1_PRIMITIVE_TAG;
|
||||||
|
if (i == V_ASN1_PRIMITIVE_TAG) { /* high-tag */
|
||||||
|
p++;
|
||||||
|
if (--max == 0)
|
||||||
|
goto err;
|
||||||
|
l = 0;
|
||||||
|
while (*p & 0x80) {
|
||||||
|
l <<= 7L;
|
||||||
|
l |= *(p++) & 0x7f;
|
||||||
|
if (--max == 0)
|
||||||
|
goto err;
|
||||||
|
if (l > (INT_MAX >> 7L))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
l <<= 7L;
|
||||||
|
l |= *(p++) & 0x7f;
|
||||||
|
tag = (int)l;
|
||||||
|
if (--max == 0)
|
||||||
|
goto err;
|
||||||
|
} else {
|
||||||
|
tag = i;
|
||||||
|
p++;
|
||||||
|
if (--max == 0)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* To avoid ambiguity with V_ASN1_NEG, impose a limit on universal tags. */
|
||||||
|
if (xclass == V_ASN1_UNIVERSAL && tag > V_ASN1_MAX_UNIVERSAL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
*ptag = tag;
|
||||||
|
*pclass = xclass;
|
||||||
|
if (!asn1_get_length(&p, &inf, plength, max))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (inf && !(ret & V_ASN1_CONSTRUCTED))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
fprintf(stderr, "p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n",
|
||||||
|
(int)p, *plength, omax, (int)*pp, (int)(p + *plength),
|
||||||
|
(int)(omax + *pp));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
if (*plength > (omax - (p - *pp))) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
|
||||||
|
/*
|
||||||
|
* Set this so that even if things are not long enough the values are
|
||||||
|
* set correctly
|
||||||
|
*/
|
||||||
|
ret |= 0x80;
|
||||||
|
}
|
||||||
|
*pp = p;
|
||||||
|
return (ret | inf);
|
||||||
|
err:
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ASN1_R_HEADER_TOO_LONG);
|
||||||
|
return (0x80);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
|
||||||
|
long max)
|
||||||
|
{
|
||||||
|
const unsigned char *p = *pp;
|
||||||
|
unsigned long ret = 0;
|
||||||
|
unsigned long i;
|
||||||
|
|
||||||
|
if (max-- < 1)
|
||||||
|
return 0;
|
||||||
|
if (*p == 0x80) {
|
||||||
|
*inf = 1;
|
||||||
|
ret = 0;
|
||||||
|
p++;
|
||||||
|
} else {
|
||||||
|
*inf = 0;
|
||||||
|
i = *p & 0x7f;
|
||||||
|
if (*(p++) & 0x80) {
|
||||||
|
if (i > sizeof(ret) || max < (long)i)
|
||||||
|
return 0;
|
||||||
|
while (i-- > 0) {
|
||||||
|
ret <<= 8L;
|
||||||
|
ret |= *(p++);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
ret = i;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Bound the length to comfortably fit in an int. Lengths in this module
|
||||||
|
* often switch between int and long without overflow checks.
|
||||||
|
*/
|
||||||
|
if (ret > INT_MAX / 2)
|
||||||
|
return 0;
|
||||||
|
*pp = p;
|
||||||
|
*rl = (long)ret;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* class 0 is constructed constructed == 2 for indefinite length constructed
|
||||||
|
*/
|
||||||
|
void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
|
||||||
|
int xclass)
|
||||||
|
{
|
||||||
|
unsigned char *p = *pp;
|
||||||
|
int i, ttag;
|
||||||
|
|
||||||
|
i = (constructed) ? V_ASN1_CONSTRUCTED : 0;
|
||||||
|
i |= (xclass & V_ASN1_PRIVATE);
|
||||||
|
if (tag < 31)
|
||||||
|
*(p++) = i | (tag & V_ASN1_PRIMITIVE_TAG);
|
||||||
|
else {
|
||||||
|
*(p++) = i | V_ASN1_PRIMITIVE_TAG;
|
||||||
|
for (i = 0, ttag = tag; ttag > 0; i++)
|
||||||
|
ttag >>= 7;
|
||||||
|
ttag = i;
|
||||||
|
while (i-- > 0) {
|
||||||
|
p[i] = tag & 0x7f;
|
||||||
|
if (i != (ttag - 1))
|
||||||
|
p[i] |= 0x80;
|
||||||
|
tag >>= 7;
|
||||||
|
}
|
||||||
|
p += ttag;
|
||||||
|
}
|
||||||
|
if (constructed == 2)
|
||||||
|
*(p++) = 0x80;
|
||||||
|
else
|
||||||
|
asn1_put_length(&p, length);
|
||||||
|
*pp = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_put_eoc(unsigned char **pp)
|
||||||
|
{
|
||||||
|
unsigned char *p = *pp;
|
||||||
|
*p++ = 0;
|
||||||
|
*p++ = 0;
|
||||||
|
*pp = p;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void asn1_put_length(unsigned char **pp, int length)
|
||||||
|
{
|
||||||
|
unsigned char *p = *pp;
|
||||||
|
int i, l;
|
||||||
|
if (length <= 127)
|
||||||
|
*(p++) = (unsigned char)length;
|
||||||
|
else {
|
||||||
|
l = length;
|
||||||
|
for (i = 0; l > 0; i++)
|
||||||
|
l >>= 8;
|
||||||
|
*(p++) = i | 0x80;
|
||||||
|
l = i;
|
||||||
|
while (i-- > 0) {
|
||||||
|
p[i] = length & 0xff;
|
||||||
|
length >>= 8;
|
||||||
|
}
|
||||||
|
p += l;
|
||||||
|
}
|
||||||
|
*pp = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_object_size(int constructed, int length, int tag)
|
||||||
|
{
|
||||||
|
int ret = 1;
|
||||||
|
if (length < 0)
|
||||||
|
return -1;
|
||||||
|
if (tag >= 31) {
|
||||||
|
while (tag > 0) {
|
||||||
|
tag >>= 7;
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (constructed == 2) {
|
||||||
|
ret += 3;
|
||||||
|
} else {
|
||||||
|
ret++;
|
||||||
|
if (length > 127) {
|
||||||
|
int tmplen = length;
|
||||||
|
while (tmplen > 0) {
|
||||||
|
tmplen >>= 8;
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret >= INT_MAX - length)
|
||||||
|
return -1;
|
||||||
|
return ret + length;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
|
||||||
|
{
|
||||||
|
if (str == NULL)
|
||||||
|
return 0;
|
||||||
|
dst->type = str->type;
|
||||||
|
if (!ASN1_STRING_set(dst, str->data, str->length))
|
||||||
|
return 0;
|
||||||
|
dst->flags = str->flags;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str)
|
||||||
|
{
|
||||||
|
ASN1_STRING *ret;
|
||||||
|
if (!str)
|
||||||
|
return NULL;
|
||||||
|
ret = ASN1_STRING_new();
|
||||||
|
if (!ret)
|
||||||
|
return NULL;
|
||||||
|
if (!ASN1_STRING_copy(ret, str)) {
|
||||||
|
ASN1_STRING_free(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||||
|
{
|
||||||
|
unsigned char *c;
|
||||||
|
const char *data = _data;
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
if (data == NULL)
|
||||||
|
return (0);
|
||||||
|
else
|
||||||
|
len = strlen(data);
|
||||||
|
}
|
||||||
|
if ((str->length <= len) || (str->data == NULL)) {
|
||||||
|
c = str->data;
|
||||||
|
if (c == NULL)
|
||||||
|
str->data = OPENSSL_malloc(len + 1);
|
||||||
|
else
|
||||||
|
str->data = OPENSSL_realloc(c, len + 1);
|
||||||
|
|
||||||
|
if (str->data == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
str->data = c;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
str->length = len;
|
||||||
|
if (data != NULL) {
|
||||||
|
OPENSSL_memcpy(str->data, data, len);
|
||||||
|
/* an allowance for strings :-) */
|
||||||
|
str->data[len] = '\0';
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
|
||||||
|
{
|
||||||
|
if (str->data)
|
||||||
|
OPENSSL_free(str->data);
|
||||||
|
str->data = data;
|
||||||
|
str->length = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_STRING_new(void)
|
||||||
|
{
|
||||||
|
return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_STRING_type_new(int type)
|
||||||
|
{
|
||||||
|
ASN1_STRING *ret;
|
||||||
|
|
||||||
|
ret = (ASN1_STRING *)OPENSSL_malloc(sizeof(ASN1_STRING));
|
||||||
|
if (ret == NULL) {
|
||||||
|
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
ret->length = 0;
|
||||||
|
ret->type = type;
|
||||||
|
ret->data = NULL;
|
||||||
|
ret->flags = 0;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_STRING_free(ASN1_STRING *a)
|
||||||
|
{
|
||||||
|
if (a == NULL)
|
||||||
|
return;
|
||||||
|
if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF))
|
||||||
|
OPENSSL_free(a->data);
|
||||||
|
OPENSSL_free(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = (a->length - b->length);
|
||||||
|
if (i == 0) {
|
||||||
|
i = OPENSSL_memcmp(a->data, b->data, a->length);
|
||||||
|
if (i == 0)
|
||||||
|
return (a->type - b->type);
|
||||||
|
else
|
||||||
|
return (i);
|
||||||
|
} else
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_STRING_length(const ASN1_STRING *x)
|
||||||
|
{
|
||||||
|
return M_ASN1_STRING_length(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASN1_STRING_length_set(ASN1_STRING *x, int len)
|
||||||
|
{
|
||||||
|
M_ASN1_STRING_length_set(x, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ASN1_STRING_type(ASN1_STRING *x)
|
||||||
|
{
|
||||||
|
return M_ASN1_STRING_type(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char *ASN1_STRING_data(ASN1_STRING *x)
|
||||||
|
{
|
||||||
|
return M_ASN1_STRING_data(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
|
||||||
|
{
|
||||||
|
return x->data;
|
||||||
|
}
|
||||||