第一次提交
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.lib filter=lfs diff=lfs merge=lfs -text
|
408
.gitignore
vendored
Normal file
@ -0,0 +1,408 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
#x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
#[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# too large to push to github, too poor to buy github lfs archives
|
||||||
|
lib/PCBInspector/lib/1_PCBModules.lib
|
||||||
|
lib/PCBInspector/lib/1_PCBModulesd.lib
|
||||||
|
|
||||||
|
# AOI Algorithm License
|
||||||
|
License.bin
|
||||||
|
/project
|
||||||
|
/lib/XImageCodecs/XImageCodecs.props
|
||||||
|
/lib/XImageCodecs/XImageCodecs.props
|
77
PreVerify.sln
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.7.34202.233
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mqtt", "mqtt\mqtt.vcxproj", "{F05F6547-2CBF-4572-BA25-6547E51F37E2}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PreVerify", "PreVerify\PreVerify.vcxproj", "{0670BD3B-C872-4B70-8E52-504F36D71361}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13} = {1119A422-2CEA-46CA-88B6-12DA05CEDF13}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logger", "logger\logger.vcxproj", "{1119A422-2CEA-46CA-88B6-12DA05CEDF13}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtYaml", "QtYaml\QtYaml.vcxproj", "{4434DF84-4E42-4E30-8F2A-A04BE89705A3}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13} = {1119A422-2CEA-46CA-88B6-12DA05CEDF13}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml2", "tinyxml2\tinyxml2.vcxproj", "{1789CC09-EBE5-46CA-9793-096DA297A421}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Debug|x86.Build.0 = Debug|x64
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{F05F6547-2CBF-4572-BA25-6547E51F37E2}.Release|x86.Build.0 = Release|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Debug|x86.Build.0 = Debug|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Release|x64.Build.0 = Release|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{0670BD3B-C872-4B70-8E52-504F36D71361}.Release|x86.Build.0 = Release|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Debug|x86.Build.0 = Debug|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Release|x64.Build.0 = Release|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{1119A422-2CEA-46CA-88B6-12DA05CEDF13}.Release|x86.Build.0 = Release|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Debug|x86.Build.0 = Debug|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Release|x64.Build.0 = Release|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Release|x86.Build.0 = Release|x64
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Release|x64.Build.0 = Release|x64
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{1789CC09-EBE5-46CA-9793-096DA297A421}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {C3F084E0-F6F4-4386-82CC-399A9907C05E}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
118
PreVerify/DefectViewCustom.cpp
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "DefectViewCustom.h"
|
||||||
|
#include "QGraphicsItemGroup"
|
||||||
|
#include "QMap.h"
|
||||||
|
#include "QList.h"
|
||||||
|
#include "QPainter"
|
||||||
|
#include "QImageReader"
|
||||||
|
#include <InspectionReferenceGenerator.h>
|
||||||
|
#include "QList"
|
||||||
|
#include "QVector"
|
||||||
|
#include "QPen"
|
||||||
|
#include "opencv2/opencv.hpp"
|
||||||
|
#include "QFile"
|
||||||
|
#include "QByteArray"
|
||||||
|
#include "qpixmapcache.h"
|
||||||
|
#include "JSONDocUtil.h"
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
DefectViewCustom::DefectViewCustom(QWidget* parent) {
|
||||||
|
QImageReader::setAllocationLimit(0);
|
||||||
|
setParent(parent);
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
setRenderHint(QPainter::Antialiasing);
|
||||||
|
setDragMode(QGraphicsView::RubberBandDrag);
|
||||||
|
setFrameShape(QFrame::NoFrame);
|
||||||
|
|
||||||
|
m_scene.setBackgroundBrush(QBrush(QColor(Qt::white)));
|
||||||
|
m_scene.addItem(&m_scanPxmpItem);
|
||||||
|
m_scene.addItem(&m_samplePxmpItem);
|
||||||
|
setScene(&m_scene);
|
||||||
|
|
||||||
|
m_titleLbl.setParent(this);
|
||||||
|
|
||||||
|
m_isValidBtn.setStyleSheet("QPushButton {background-color: transparent; border: none;}");
|
||||||
|
m_isValidBtn.setCheckable(true);
|
||||||
|
m_isValidBtn.setGeometry(this->geometry());
|
||||||
|
m_isValidBtn.setParent(this);
|
||||||
|
m_isValidBtn.setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefectViewCustom::load(QString filePath, int defectId, bool isValid, double x, double y, QString jobLayer, QPixmap& samplePxmp, int defectType, int rowHeight, bool containSample) {
|
||||||
|
this->setFixedHeight(rowHeight);
|
||||||
|
m_isValidBtn.setGeometry(this->geometry());
|
||||||
|
//加载扫描图
|
||||||
|
QPixmap* scanPxmp = new QPixmap(filePath, nullptr, Qt::NoFormatConversion);
|
||||||
|
double width = scanPxmp->width();
|
||||||
|
double height = scanPxmp->height();
|
||||||
|
*scanPxmp = scanPxmp->scaled(200, 200, Qt::KeepAspectRatio);
|
||||||
|
m_scanPxmpItem.setPixmap(*scanPxmp);
|
||||||
|
m_scanPxmpItem.setPos(0, 0);
|
||||||
|
|
||||||
|
if (containSample) {
|
||||||
|
//加载参考图
|
||||||
|
double pixSize = 15.937359904903442;
|
||||||
|
double xx = x / pixSize;
|
||||||
|
double yy = samplePxmp.height() - y / pixSize;
|
||||||
|
QPixmap copy = samplePxmp.copy(QRect(xx - width / 2, yy - height / 2, width, height));
|
||||||
|
copy = copy.scaled(200, 200, Qt::KeepAspectRatio);
|
||||||
|
m_samplePxmpItem.setPixmap(copy);
|
||||||
|
m_samplePxmpItem.setPos(0, scanPxmp->height() + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setObjectName(QString::number(defectId));
|
||||||
|
m_titleLbl.setText(QString("%1:%2").arg(defectId).arg(m_preVerifyWgt->defectId2Desc(defectType)));
|
||||||
|
if (!isValid) {
|
||||||
|
m_isValidBtn.setChecked(true);
|
||||||
|
m_isValidBtn.setStyleSheet("QPushButton {background-color: rgba(0, 255, 0, 60); border: none;}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefectViewCustom::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
QGraphicsView::mouseMoveEvent(event);
|
||||||
|
QPointF pos = mapToScene(event->pos());
|
||||||
|
setToolTip(QString("X: %1, Y: %2").arg(pos.x()).arg(pos.y()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefectViewCustom::wheelEvent(QWheelEvent* e) {
|
||||||
|
int delta = e->angleDelta().y();
|
||||||
|
if (delta > 0) {
|
||||||
|
scale(1.2, 1.2);
|
||||||
|
}
|
||||||
|
else if (delta < 0) {
|
||||||
|
scale(1 / 1.2, 1 / 1.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefectViewCustom::mousePressEvent(QMouseEvent* event) {
|
||||||
|
QGraphicsView::mousePressEvent(event);
|
||||||
|
bool checked = m_isValidBtn.isChecked();
|
||||||
|
m_isValidBtn.setChecked(!checked);
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
m_isValidBtn.setStyleSheet("QPushButton {background-color: transparent; border: none;}");
|
||||||
|
m_preVerifyWgt->updateOne(this->objectName(), 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_isValidBtn.setStyleSheet("QPushButton {background-color: rgba(0, 255, 0, 60); border: none;}");
|
||||||
|
m_preVerifyWgt->updateOne(this->objectName(), -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefectViewCustom::keyPressEvent(QKeyEvent* event) {
|
||||||
|
m_preVerifyWgt->keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefectViewCustom::hideCam(int state) {
|
||||||
|
if (state == 0) {
|
||||||
|
m_samplePxmpItem.hide();
|
||||||
|
}
|
||||||
|
else if (state == 2) {
|
||||||
|
m_samplePxmpItem.show();
|
||||||
|
}
|
||||||
|
}
|
42
PreVerify/DefectViewCustom.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <qgraphicsview.h>
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include <QList>
|
||||||
|
#include "QGraphicsItemGroup"
|
||||||
|
#include "QPixmap"
|
||||||
|
#include "QPoint"
|
||||||
|
#include "QMouseEvent"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "QPushButton"
|
||||||
|
#include "QLabel"
|
||||||
|
#include "PreVerifyWidget.h"
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DefectViewCustom : public QGraphicsView {
|
||||||
|
Q_OBJECT
|
||||||
|
LOG4QT_DECLARE_QCLASS_LOGGER
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGraphicsScene m_scene;
|
||||||
|
QGraphicsPixmapItem m_scanPxmpItem;
|
||||||
|
QGraphicsPixmapItem m_samplePxmpItem;
|
||||||
|
QLabel m_titleLbl;
|
||||||
|
QPushButton m_isValidBtn;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
DefectViewCustom(QWidget* parent = nullptr);
|
||||||
|
void load(QString filePath, int defectId, bool isValid, double x, double y, QString jobLayer, QPixmap& samplePxmp, int defectType, int rowHeight, bool containSample);
|
||||||
|
void hideCam(int state);
|
||||||
|
void wheelEvent(QWheelEvent* e) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
PreVerifyWidget* m_preVerifyWgt;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
BIN
PreVerify/DefectViewCustom.zip
Normal file
34
PreVerify/JSONDocUtil.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "JSONDocUtil.h"
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include "JSONUtil.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool JSONDocUtil::readJSONDoc(QString filePath, QJsonObject& obj) {
|
||||||
|
QFile file(filePath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
l4qInfo(QString("%1 文件不存在").arg(file.fileName()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
l4qError(QString("%1 文件读异常").arg(file.fileName()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QByteArray jsonData(file.readAll());
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
JSONUtil::getInstance().parse(jsonData, obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JSONDocUtil::writeJSONDoc(QString filePath, QJsonObject& obj) {
|
||||||
|
QFile file(filePath);
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
||||||
|
l4qError(QString("%1 文件写异常").arg(filePath));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
file.write(QJsonDocument(obj).toJson());
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
}
|
25
PreVerify/JSONDocUtil.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "qobject.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
|
||||||
|
class JSONDocUtil : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
LOG4QT_DECLARE_QCLASS_LOGGER
|
||||||
|
|
||||||
|
private:
|
||||||
|
JSONDocUtil() {};
|
||||||
|
Q_DISABLE_COPY_MOVE(JSONDocUtil);
|
||||||
|
public:
|
||||||
|
~JSONDocUtil() {};
|
||||||
|
static JSONDocUtil& getInstance() {
|
||||||
|
static JSONDocUtil instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool readJSONDoc(QString filePath, QJsonObject& obj);
|
||||||
|
bool writeJSONDoc(QString filePath, QJsonObject& obj);
|
||||||
|
};
|
||||||
|
|
56
PreVerify/JSONUtil.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include "JSONUtil.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool JSONUtil::parse(const char* buf, QJsonObject& obj) {
|
||||||
|
QJsonParseError json_error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(buf, &json_error);
|
||||||
|
if (json_error.error != QJsonParseError::NoError) {
|
||||||
|
l4qError("json格式转换错误: " + json_error.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!jsonDoc.isObject()) {
|
||||||
|
l4qError("不是Json对象");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
obj = jsonDoc.object();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JSONUtil::parse(const std::string& payload, QJsonObject* obj) {
|
||||||
|
QJsonParseError json_error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload.c_str(), &json_error);
|
||||||
|
if (json_error.error != QJsonParseError::NoError) {
|
||||||
|
l4qError("扫描结果json格式转换错误: " + json_error.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!jsonDoc.isObject()) {
|
||||||
|
l4qError("扫描结果不是Json对象");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*obj = jsonDoc.object();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JSONUtil::parse(const std::string& payload, QJsonArray* array) {
|
||||||
|
QJsonParseError json_error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload.c_str(), &json_error);
|
||||||
|
if (json_error.error != QJsonParseError::NoError) {
|
||||||
|
l4qError("扫描结果json格式转换错误: " + json_error.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!jsonDoc.isArray()) {
|
||||||
|
l4qError("扫描结果不是Json数组");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*array = jsonDoc.array();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JSONUtil::parse(const std::string& payload, QVariantMap* map) {
|
||||||
|
QJsonObject obj;
|
||||||
|
if (!parse(payload, &obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*map = obj.toVariantMap();
|
||||||
|
return true;
|
||||||
|
}
|
29
PreVerify/JSONUtil.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QVariantMap>
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
|
||||||
|
class JSONUtil : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
LOG4QT_DECLARE_QCLASS_LOGGER
|
||||||
|
|
||||||
|
private:
|
||||||
|
JSONUtil() {};
|
||||||
|
Q_DISABLE_COPY_MOVE(JSONUtil);
|
||||||
|
public:
|
||||||
|
static JSONUtil& getInstance() {
|
||||||
|
static JSONUtil instance;
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool parse(const char* buf, QJsonObject& obj);
|
||||||
|
bool parse(const std::string& payload, QJsonObject* obj);
|
||||||
|
bool parse(const std::string& payload, QJsonArray* array);
|
||||||
|
bool parse(const std::string& payload, QVariantMap* map);
|
||||||
|
|
||||||
|
};
|
78
PreVerify/MainWidget.cpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include "MainWidget.h"
|
||||||
|
#include "QFont"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MainWidget::MainWidget(QWidget* parent) {
|
||||||
|
setUi();
|
||||||
|
setConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWidget::~MainWidget() {
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::setUi() {
|
||||||
|
resize(1600, 900);
|
||||||
|
m_centralWgt.setLayout(&m_centralLt);
|
||||||
|
this->setCentralWidget(&m_centralWgt);
|
||||||
|
|
||||||
|
m_centralLt.addWidget(&m_menuWgt);
|
||||||
|
m_centralLt.addWidget(&m_contentWgt);
|
||||||
|
m_menuWgt.setFixedWidth(100);
|
||||||
|
m_menuWgt.setStyleSheet("background-color: blue;");
|
||||||
|
m_centralLt.setAlignment(Qt::AlignLeft);
|
||||||
|
|
||||||
|
m_menuWgt.setLayout(&m_menuLt);
|
||||||
|
m_menuLt.setAlignment(Qt::AlignTop);
|
||||||
|
|
||||||
|
m_menuGrp.addButton(&m_preVerifyBtn, 0);
|
||||||
|
m_menuGrp.addButton(&m_paramSettingBtn, 0);
|
||||||
|
m_menuGrp.setExclusive(true);
|
||||||
|
|
||||||
|
m_preVerifyBtn.setFixedWidth(100);
|
||||||
|
m_preVerifyBtn.setFixedHeight(60);
|
||||||
|
m_preVerifyBtn.setText("复 判");
|
||||||
|
m_preVerifyBtn.setStyleSheet("background-color: cyan; font: 15pt; ");
|
||||||
|
m_preVerifyBtn.setCheckable(true);
|
||||||
|
|
||||||
|
m_paramSettingBtn.setFixedWidth(100);
|
||||||
|
m_paramSettingBtn.setFixedHeight(60);
|
||||||
|
m_paramSettingBtn.setText("参 数");
|
||||||
|
m_paramSettingBtn.setStyleSheet("background-color: cyan; font: 18pt; ");
|
||||||
|
m_paramSettingBtn.setCheckable(true);
|
||||||
|
|
||||||
|
m_menuLt.addWidget(&m_preVerifyBtn);
|
||||||
|
m_menuLt.addWidget(&m_paramSettingBtn);
|
||||||
|
|
||||||
|
m_contentWgt.addWidget(&m_preVerifyWgt);
|
||||||
|
m_contentWgt.addWidget(&m_paramSettingWgt);
|
||||||
|
m_contentWgt.setFrameShape(QFrame::Panel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::setConnection() {
|
||||||
|
QObject::connect(&m_preVerifyBtn, &QPushButton::pressed, this, &MainWidget::slot_preVerifyBtnPressed);
|
||||||
|
QObject::connect(&m_paramSettingBtn, &QPushButton::pressed, this, &MainWidget::slot_paramSettingBtnPressed);
|
||||||
|
QObject::connect(this, &MainWidget::sig_winStateChangeEvent, &m_preVerifyWgt, &PreVerifyWidget::slot_winStateChangeEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::load() {
|
||||||
|
m_preVerifyBtn.setChecked(true);
|
||||||
|
slot_preVerifyBtnPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::slot_preVerifyBtnPressed() {
|
||||||
|
m_contentWgt.setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::slot_paramSettingBtnPressed() {
|
||||||
|
m_contentWgt.setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWidget::changeEvent(QEvent* event) {
|
||||||
|
if (event->type() == QEvent::WindowStateChange) {
|
||||||
|
emit sig_winStateChangeEvent();
|
||||||
|
}
|
||||||
|
QWidget::changeEvent(event);
|
||||||
|
}
|
45
PreVerify/MainWidget.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "qpushbutton.h"
|
||||||
|
#include "QHBoxLayout"
|
||||||
|
#include "QVBoxLayout"
|
||||||
|
#include "QPushButton"
|
||||||
|
#include "qstackedwidget.h"
|
||||||
|
#include "PreVerifyWidget.h"
|
||||||
|
#include "qbuttongroup.h"
|
||||||
|
#include "QEvent"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MainWidget : public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MainWidget(QWidget* parent = nullptr);
|
||||||
|
~MainWidget();
|
||||||
|
void setUi();
|
||||||
|
void setConnection();
|
||||||
|
void load();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slot_preVerifyBtnPressed();
|
||||||
|
void slot_paramSettingBtnPressed();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget m_centralWgt;
|
||||||
|
QHBoxLayout m_centralLt;
|
||||||
|
QWidget m_menuWgt;
|
||||||
|
QStackedWidget m_contentWgt;
|
||||||
|
QVBoxLayout m_menuLt;
|
||||||
|
QPushButton m_preVerifyBtn; //复判
|
||||||
|
QPushButton m_paramSettingBtn; //参数
|
||||||
|
PreVerifyWidget m_preVerifyWgt;
|
||||||
|
QWidget m_paramSettingWgt;
|
||||||
|
QButtonGroup m_menuGrp;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void changeEvent(QEvent* event) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sig_winStateChangeEvent();
|
||||||
|
};
|
17
PreVerify/PreVerify.exe.log4qt.properties
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
logpath=./logs
|
||||||
|
log4j.reset=true
|
||||||
|
log4j.Debug=WARN
|
||||||
|
log4j.threshold=NULL
|
||||||
|
log4j.handleQtMessages=true
|
||||||
|
log4j.watchThisFile=false
|
||||||
|
|
||||||
|
log4j.rootLogger=ALL, console, daily
|
||||||
|
|
||||||
|
log4j.appender.daily=org.apache.log4j.DailyFileAppender
|
||||||
|
log4j.appender.daily.file=${logpath}/PreVerify.log
|
||||||
|
log4j.appender.daily.appendFile=true
|
||||||
|
log4j.appender.daily.datePattern=_yyyy-MM-dd
|
||||||
|
log4j.appender.daily.layout.dateFormat=yyyy-MM-dd hh:mm:ss.zzz
|
||||||
|
log4j.appender.daily.keepDays=7
|
||||||
|
log4j.appender.daily.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.daily.layout.conversionPattern=%d{yyyy-MM-dd hh:mm:ss.zzz} [%p] [%t] [%r] %F:%L%n %m%n
|
9
PreVerify/PreVerify.qrc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>res/ico/dateClear.png</file>
|
||||||
|
<file>res/ico/lastBoard.png</file>
|
||||||
|
<file>res/ico/lastDefect.png</file>
|
||||||
|
<file>res/ico/nextBoard.png</file>
|
||||||
|
<file>res/ico/nextDefect.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
180
PreVerify/PreVerify.vcxproj
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{0670BD3B-C872-4B70-8E52-504F36D71361}</ProjectGuid>
|
||||||
|
<Keyword>QtVS_v304</Keyword>
|
||||||
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0.22621.0</WindowsTargetPlatformVersion>
|
||||||
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
|
||||||
|
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||||
|
<ProjectName>PreVerify</ProjectName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
||||||
|
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||||
|
<QtInstall>QT6.5</QtInstall>
|
||||||
|
<QtModules>core;gui;network;widgets;serialbus;serialport;sql;xml;charts;datavisualization</QtModules>
|
||||||
|
<QtBuildConfig>debug</QtBuildConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||||
|
<QtInstall>QT6.5</QtInstall>
|
||||||
|
<QtModules>core;gui;widgets</QtModules>
|
||||||
|
<QtBuildConfig>release</QtBuildConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||||
|
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||||
|
</Target>
|
||||||
|
<ImportGroup Label="ExtensionSettings" />
|
||||||
|
<ImportGroup Label="Shared" />
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||||
|
<Import Project="..\lib\log4Qt\log4qt.props" />
|
||||||
|
<Import Project="..\lib\yaml\yaml.props" />
|
||||||
|
<Import Project="..\lib\opencv480\opencv480.props" />
|
||||||
|
<Import Project="..\lib\PCBInspector\PCBInspector.props" />
|
||||||
|
<Import Project="..\lib\ReferenceDataGenerator\ReferenceDataGenerator.props" />
|
||||||
|
<Import Project="..\lib\DVP2\DVP2.props" />
|
||||||
|
<Import Project="..\lib\qtl\qtl.props" />
|
||||||
|
<Import Project="..\lib\mysql\mysql.props" />
|
||||||
|
<Import Project="..\lib\OpenSSL\OpenSSL.props" />
|
||||||
|
<Import Project="..\lib\XDongleVerifier\XDongleVerifier.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||||
|
<Import Project="..\lib\yaml\yaml.props" />
|
||||||
|
<Import Project="..\lib\opencv480\opencv480.props" />
|
||||||
|
<Import Project="..\lib\PCBInspector\PCBInspector.props" />
|
||||||
|
<Import Project="..\lib\ReferenceDataGenerator\ReferenceDataGenerator.props" />
|
||||||
|
<Import Project="..\lib\OpenSSL\OpenSSL.props" />
|
||||||
|
<Import Project="..\lib\qtl\qtl.props" />
|
||||||
|
<Import Project="..\lib\XDongleVerifier\XDongleVerifier.props" />
|
||||||
|
<Import Project="..\lib\mysql\mysql.props" />
|
||||||
|
<Import Project="..\lib\log4Qt\log4qt.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<TargetName>PreVerify</TargetName>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(OutDir);</AdditionalLibraryDirectories>
|
||||||
|
<NoEntryPoint>false</NoEntryPoint>
|
||||||
|
</Link>
|
||||||
|
<ClCompile>
|
||||||
|
<PreprocessorDefinitions>YAML_CPP_STATIC_DEFINE;MODE_DEV;PAHO_HIGH_PERFORMANCE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)logger;$(Qt_INCLUDEPATH_)</AdditionalIncludeDirectories>
|
||||||
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>
|
||||||
|
</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(Qt_INCLUDEPATH_);$(SolutionDir)mqtt\paho.mqtt.cpp;$(SolutionDir)mqtt\paho.mqtt.c;$(SolutionDir)QtYaml;$(SolutionDir)logger;$(SolutionDir)tinyxml2;$(SolutionDir)lib\XImageCodecs\include</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>YAML_CPP_STATIC_DEFINE;MODE_DEV;PAHO_HIGH_PERFORMANCE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<DisableSpecificWarnings>4828</DisableSpecificWarnings>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalLibraryDirectories>$(OutDir);$(SolutionDir)lib\paho.mqtt.c\lib;$(SolutionDir)lib\paho.mqtt.cpp\lib;$(SolutionDir)lib\XImageCodecs\lib</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>mqtt.lib;ws2_32.lib;QtYamld.lib;loggerd.lib;tinyxml2d.lib;XImageCodecsd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>
|
||||||
|
</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
<ClCompile>
|
||||||
|
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||||
|
<ClCompile>
|
||||||
|
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="PreVerify.exe.log4qt.properties" />
|
||||||
|
<None Include="PreVerify.yml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="DefectViewCustom.cpp" />
|
||||||
|
<ClCompile Include="JSONDocUtil.cpp" />
|
||||||
|
<ClCompile Include="JSONUtil.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="MainWidget.cpp" />
|
||||||
|
<ClCompile Include="PreVerifyWidget.cpp" />
|
||||||
|
<ClCompile Include="ScrollAreaCustom.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<QtMoc Include="MainWidget.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="ScrollAreaCustom.h" />
|
||||||
|
<QtMoc Include="JSONDocUtil.h" />
|
||||||
|
<QtMoc Include="JSONUtil.h" />
|
||||||
|
<QtMoc Include="DefectViewCustom.h" />
|
||||||
|
<ClInclude Include="PreVerifyWidget.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<QtRcc Include="PreVerify.qrc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||||
|
<Import Project="$(QtMsBuild)\qt.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
64
PreVerify/PreVerify.vcxproj.filters
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{96cda2d9-e17b-400c-9897-ea193805115d}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{c6cd4fde-9f46-4172-8353-5d2f0d23a2ef}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Form Files">
|
||||||
|
<UniqueIdentifier>{1152de46-21c1-49c3-95d9-742a30b31b6c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="main">
|
||||||
|
<UniqueIdentifier>{5a7ec928-2fc6-4024-9468-6deb6e299028}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="utils">
|
||||||
|
<UniqueIdentifier>{7630d594-8c7c-4b8e-b52e-948aa2bbc118}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="MainWidget.cpp">
|
||||||
|
<Filter>main</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="main.cpp">
|
||||||
|
<Filter>main</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="PreVerifyWidget.cpp" />
|
||||||
|
<ClCompile Include="JSONDocUtil.cpp">
|
||||||
|
<Filter>utils</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="JSONUtil.cpp">
|
||||||
|
<Filter>utils</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DefectViewCustom.cpp" />
|
||||||
|
<ClCompile Include="ScrollAreaCustom.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<QtMoc Include="MainWidget.h">
|
||||||
|
<Filter>main</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="JSONDocUtil.h">
|
||||||
|
<Filter>utils</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="JSONUtil.h">
|
||||||
|
<Filter>utils</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="DefectViewCustom.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="PreVerify.yml">
|
||||||
|
<Filter>main</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="PreVerify.exe.log4qt.properties">
|
||||||
|
<Filter>main</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="PreVerifyWidget.h" />
|
||||||
|
<ClInclude Include="ScrollAreaCustom.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<QtRcc Include="PreVerify.qrc" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
0
PreVerify/PreVerify.yml
Normal file
742
PreVerify/PreVerifyWidget.cpp
Normal file
@ -0,0 +1,742 @@
|
|||||||
|
#include "PreVerifyWidget.h"
|
||||||
|
#include "QDir"
|
||||||
|
#include "QTreeWidgetItem"
|
||||||
|
#include "QHeaderView"
|
||||||
|
#include "JSONDocUtil.h"
|
||||||
|
#include "QHash"
|
||||||
|
#include "QJsonObject"
|
||||||
|
#include "QJsonDocument"
|
||||||
|
#include "QJsonArray"
|
||||||
|
#include "DefectViewCustom.h"
|
||||||
|
#include "qscrollbar.h"
|
||||||
|
#include "QBrush"
|
||||||
|
#include "QColor"
|
||||||
|
#include "QImageReader"
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include "qpixmapcache.h"
|
||||||
|
#include "QSpacerItem"
|
||||||
|
#include "qmessagebox.h"
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
|
||||||
|
PreVerifyWidget::PreVerifyWidget(QWidget* parent) {
|
||||||
|
QPixmapCache::setCacheLimit(8 * 1024 * 1024);
|
||||||
|
setUi();
|
||||||
|
setConnection();
|
||||||
|
readDefectTypesDesc();
|
||||||
|
load();
|
||||||
|
filter();
|
||||||
|
loadDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
PreVerifyWidget::~PreVerifyWidget() {
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::setUi() {
|
||||||
|
setLayout(&m_lt);
|
||||||
|
m_lt.addLayout(&m_leftLt, 3);
|
||||||
|
m_lt.addLayout(&m_rightLt, 11);
|
||||||
|
|
||||||
|
labelY.setText("年");
|
||||||
|
labelM.setText("月");
|
||||||
|
labelD.setText("日");
|
||||||
|
|
||||||
|
m_spinY.setMaximum(3000);
|
||||||
|
m_spinY.setFixedWidth(70);
|
||||||
|
m_spinY.setMinimum(1900);
|
||||||
|
m_spinY.setValue(QDate::currentDate().year());
|
||||||
|
m_spinM.setMaximum(12);
|
||||||
|
m_spinM.setMinimum(1);
|
||||||
|
m_spinM.setFixedWidth(40);
|
||||||
|
m_spinM.setValue(QDate::currentDate().month());
|
||||||
|
m_spinD.setMaximum(31);
|
||||||
|
m_spinD.setMinimum(1);
|
||||||
|
m_spinD.setFixedWidth(40);
|
||||||
|
m_spinD.setValue(QDate::currentDate().day());
|
||||||
|
m_dateLt.addWidget(&m_spinY);
|
||||||
|
m_dateLt.addWidget(&labelY);
|
||||||
|
m_dateLt.addWidget(&m_yearClearBtn);
|
||||||
|
m_dateLt.addWidget(&m_spinM);
|
||||||
|
m_dateLt.addWidget(&labelM);
|
||||||
|
m_dateLt.addWidget(&m_monthClearBtn);
|
||||||
|
m_dateLt.addWidget(&m_spinD);
|
||||||
|
m_dateLt.addWidget(&labelD);
|
||||||
|
m_dateLt.addWidget(&m_dateClearBtn);
|
||||||
|
|
||||||
|
|
||||||
|
label1.setText("批号:");
|
||||||
|
label11.setText("批号:");
|
||||||
|
label2.setText("板号:");
|
||||||
|
label3.setText("料号:");
|
||||||
|
label4.setText("层号:");
|
||||||
|
label1.setFixedWidth(30);
|
||||||
|
label11.setFixedWidth(30);
|
||||||
|
m_yearClearBtn.setFixedWidth(25);
|
||||||
|
m_monthClearBtn.setFixedWidth(25);
|
||||||
|
m_dateClearBtn.setFixedWidth(25);
|
||||||
|
//m_leftLt.addWidget(&label1, 0, 0);
|
||||||
|
//m_leftLt.addLayout(&m_dateLt, 0, 1, 1, 2);
|
||||||
|
m_leftLt.addWidget(&label11, 1, 0);
|
||||||
|
m_leftLt.addWidget(&m_dateCmb, 1, 1, 1, 2);
|
||||||
|
m_leftLt.addWidget(&label2, 2, 0);
|
||||||
|
m_leftLt.addWidget(&m_boardIdEdt, 2, 1, 1, 2);
|
||||||
|
m_leftLt.addWidget(&label3, 3, 0);
|
||||||
|
m_leftLt.addWidget(&m_jobEdt, 3, 1, 1, 2);
|
||||||
|
m_leftLt.addWidget(&label4, 4, 0);
|
||||||
|
m_leftLt.addWidget(&m_layerEdt, 4, 1, 1, 2);
|
||||||
|
m_leftLt.addWidget(&m_treeWgt, 5, 0, 1, 3);
|
||||||
|
|
||||||
|
m_dateEdt.setCalendarPopup(true);
|
||||||
|
m_dateEdt.setDate(QDate::currentDate());
|
||||||
|
m_dateEdt.setDisplayFormat("yyyy-MM-dd");
|
||||||
|
m_yearClearBtn.setIcon(QIcon(":/res/ico/dateClear.png"));
|
||||||
|
m_monthClearBtn.setIcon(QIcon(":/res/ico/dateClear.png"));
|
||||||
|
m_dateClearBtn.setIcon(QIcon(":/res/ico/dateClear.png"));
|
||||||
|
|
||||||
|
m_pageBtnLt.addWidget(&m_lastBoardBtn);
|
||||||
|
m_pageBtnLt.addWidget(&m_lastDefectBtn);
|
||||||
|
m_pageBtnLt.addWidget(&m_curDefectLbl);
|
||||||
|
m_pageBtnLt.addWidget(&m_nextDefectBtn);
|
||||||
|
m_pageBtnLt.addWidget(&m_nextBoardBtn);
|
||||||
|
m_pageBtnLt.addWidget(&m_showCamChk);
|
||||||
|
m_pageBtnLt.addWidget(&m_showDefectCountLbl);
|
||||||
|
m_pageBtnLt.addWidget(&m_showDefectCountCmb);
|
||||||
|
int width = 60;
|
||||||
|
int height = 40;
|
||||||
|
m_lastBoardBtn.setFixedSize(width, height);
|
||||||
|
m_lastDefectBtn.setFixedSize(width, height);
|
||||||
|
m_curDefectLbl.setFixedSize(150, height);
|
||||||
|
m_nextDefectBtn.setFixedSize(width, height);
|
||||||
|
m_nextBoardBtn.setFixedSize(width, height);
|
||||||
|
m_curDefectLbl.setText(" 0 : :0/0");
|
||||||
|
m_curDefectLbl.setAlignment(Qt::AlignCenter);
|
||||||
|
m_lastBoardBtn.setIcon(QIcon(":/res/ico/lastBoard.png"));
|
||||||
|
m_lastDefectBtn.setIcon(QIcon(":/res/ico/lastDefect.png"));
|
||||||
|
m_nextDefectBtn.setIcon(QIcon(":/res/ico/nextDefect.png"));
|
||||||
|
m_nextBoardBtn.setIcon(QIcon(":/res/ico/nextBoard.png"));
|
||||||
|
m_showCamChk.setText("显示CAM图");
|
||||||
|
m_showCamChk.setLayoutDirection(Qt::RightToLeft);
|
||||||
|
m_showCamChk.setChecked(true);
|
||||||
|
m_showCamChk.setGeometry(0, 0, m_showCamChk.width(), m_showCamChk.height());
|
||||||
|
m_showDefectCountLbl.setText(" 每页缺陷数:");
|
||||||
|
m_showDefectCountLbl.setFixedWidth(95);
|
||||||
|
m_showDefectCountCmb.setFixedWidth(90);
|
||||||
|
m_showDefectCountCmb.addItem(" 1 x 2");
|
||||||
|
m_showDefectCountCmb.addItem(" 1 x 3");
|
||||||
|
m_showDefectCountCmb.addItem(" 2 x 4");
|
||||||
|
m_showDefectCountCmb.addItem(" 2 x 5");
|
||||||
|
m_showDefectCountCmb.setCurrentIndex(3);
|
||||||
|
|
||||||
|
m_rightLt.addLayout(&m_pageBtnLt);
|
||||||
|
m_rightLt.addWidget(&m_grdScr);
|
||||||
|
|
||||||
|
m_grdScr.setWidget(&m_grdWgt);
|
||||||
|
m_grdScr.setWidgetResizable(true);
|
||||||
|
m_grdScr.verticalScrollBar()->setTracking(true);
|
||||||
|
m_grdScr.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
m_grdScr.verticalScrollBar()->setSingleStep(m_grdScr.height());
|
||||||
|
|
||||||
|
|
||||||
|
m_grdWgt.setLayout(&m_grdLt);
|
||||||
|
m_grdLt.setSpacing(10);
|
||||||
|
m_grdLt.setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_grdLt.setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||||
|
|
||||||
|
|
||||||
|
QStringList treeHeaders;
|
||||||
|
treeHeaders << "料号/层号" << "板号" << "A/B面" << "有效/总缺陷";
|
||||||
|
m_treeWgt.setIndentation(5);
|
||||||
|
m_treeWgt.setColumnCount(treeHeaders.size());
|
||||||
|
m_treeWgt.setHeaderLabels(treeHeaders);
|
||||||
|
m_treeWgt.header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
m_treeWgt.setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::setConnection() {
|
||||||
|
QObject::connect(&m_yearClearBtn, &QPushButton::pressed, [=]() {
|
||||||
|
m_spinY.clear();
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_monthClearBtn, &QPushButton::pressed, [=]() {
|
||||||
|
m_spinM.clear();
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_dateClearBtn, &QPushButton::pressed, [=]() {
|
||||||
|
m_spinD.clear();
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinY, &QSpinBox::valueChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinY, &QSpinBox::textChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinY, &QSpinBox::editingFinished, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinM, &QSpinBox::valueChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinM, &QSpinBox::textChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinM, &QSpinBox::editingFinished, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinD, &QSpinBox::valueChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinD, &QSpinBox::textChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_spinD, &QSpinBox::editingFinished, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_boardIdEdt, &QLineEdit::textChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_jobEdt, &QLineEdit::textChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_layerEdt, &QLineEdit::textChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_showCamChk, &QCheckBox::stateChanged, [=](int state) {
|
||||||
|
slot_treeWgtCurrentItemChanged(m_treeWgt.currentItem(), nullptr);
|
||||||
|
});
|
||||||
|
QObject::connect(&m_showDefectCountCmb, &QComboBox::currentIndexChanged, [=]() {
|
||||||
|
if (m_treeWgt.currentItem() != nullptr) {
|
||||||
|
slot_treeWgtCurrentItemChanged(m_treeWgt.currentItem(), nullptr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
QObject::connect(&m_dateCmb, &QComboBox::currentTextChanged, [=]() {
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
QObject::connect(&m_treeWgt, &QTreeWidget::currentItemChanged, this, &PreVerifyWidget::slot_treeWgtCurrentItemChanged);
|
||||||
|
QObject::connect(&m_lastBoardBtn, &QPushButton::pressed, this, &PreVerifyWidget::slot_lastBoardBtnPressed);
|
||||||
|
QObject::connect(&m_lastDefectBtn, &QPushButton::pressed, this, &PreVerifyWidget::slot_lastDefectBtnPressed);
|
||||||
|
QObject::connect(&m_nextBoardBtn, &QPushButton::pressed, this, &PreVerifyWidget::slot_nextBoardBtnPressed);
|
||||||
|
QObject::connect(&m_nextDefectBtn, &QPushButton::pressed, this, &PreVerifyWidget::slot_nextDefectBtnPressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::loadDate() {
|
||||||
|
m_dateCmb.addItem("");
|
||||||
|
QString path = "D:/PCBDataset/Defect/fengming/AOI_DEFECT";
|
||||||
|
QJsonObject yearJson;
|
||||||
|
|
||||||
|
QDir rootDir(path);
|
||||||
|
QStringList dateList = rootDir.entryList(QDir::NoDotAndDotDot | QDir::AllDirs, QDir::Time);
|
||||||
|
for (QString date : dateList) {
|
||||||
|
m_dateCmb.addItem(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::showDefectCountCmbIndexChanged() {
|
||||||
|
int ix = m_showDefectCountCmb.currentIndex();
|
||||||
|
switch (ix) {
|
||||||
|
case 0:
|
||||||
|
m_rowCount = 1;
|
||||||
|
m_colCount = 2;
|
||||||
|
m_rowHeight = m_grdScr.height() - m_grdLt.spacing();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
m_rowCount = 1;
|
||||||
|
m_colCount = 3;
|
||||||
|
m_rowHeight = m_grdScr.height() - m_grdLt.spacing();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
m_rowCount = 2;
|
||||||
|
m_colCount = 4;
|
||||||
|
m_rowHeight = m_grdScr.height() / 2 - m_grdLt.spacing();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
m_rowCount = 2;
|
||||||
|
m_colCount = 5;
|
||||||
|
m_rowHeight = m_grdScr.height() / 2 - m_grdLt.spacing();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::readDefectTypesDesc() {
|
||||||
|
JSONDocUtil::getInstance().readJSONDoc("D:/PCBDataset/GlobalSettings/defectTypeDescription.json", m_defectTypesDescJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PreVerifyWidget::defectId2Desc(int defectId) {
|
||||||
|
return m_defectTypesDescJson.value(QString::number(defectId)).toObject().value("cn").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::load() {
|
||||||
|
loadTreeWgt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::loadTreeWgt() {
|
||||||
|
m_treeWgt.clear();
|
||||||
|
|
||||||
|
QString path = "D:/PCBDataset/Defect/fengming/AOI_DEFECT";
|
||||||
|
QJsonObject yearJson;
|
||||||
|
|
||||||
|
//创建文件夹Json对象
|
||||||
|
toJson(yearJson, path);
|
||||||
|
|
||||||
|
//创建文件夹树
|
||||||
|
for (QString yearKey : yearJson.keys()) {
|
||||||
|
QTreeWidgetItem* yearItem = new QTreeWidgetItem(&m_treeWgt);
|
||||||
|
yearItem->setText(0, yearKey);
|
||||||
|
|
||||||
|
QJsonObject monthJson = yearJson.value(yearKey).toObject();
|
||||||
|
for (QString monthKey : monthJson.keys()) {
|
||||||
|
QTreeWidgetItem* monthItem = new QTreeWidgetItem(yearItem);
|
||||||
|
monthItem->setText(0, monthKey);
|
||||||
|
|
||||||
|
QJsonArray dateArr = monthJson.value(monthKey).toArray();
|
||||||
|
for (int i = 0; i < dateArr.size(); i++) {
|
||||||
|
QString dateKey = dateArr.at(i).toString();
|
||||||
|
QTreeWidgetItem* dateItem = new QTreeWidgetItem(monthItem);
|
||||||
|
dateItem->setText(0, dateKey);
|
||||||
|
|
||||||
|
//创建板数据
|
||||||
|
QString datePath = path + "/" + dateKey;
|
||||||
|
QDir datDir(datePath);
|
||||||
|
QStringList boardIdList = datDir.entryList(QDir::NoDotAndDotDot | QDir::AllDirs);
|
||||||
|
for (QString boardId : boardIdList) {
|
||||||
|
bool isInt = true;
|
||||||
|
boardId.toInt(&isInt);
|
||||||
|
if (!isInt) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString boardIdPath = datePath + "/" + boardId;
|
||||||
|
|
||||||
|
for (char i = 'A'; i <= 'B'; i++) {
|
||||||
|
QTreeWidgetItem* item;
|
||||||
|
QString vrsPath = boardIdPath + "/" + i + ".vrs";
|
||||||
|
|
||||||
|
//备份
|
||||||
|
QFile file = QFile(vrsPath);
|
||||||
|
if (file.exists()) {
|
||||||
|
file.copy(boardIdPath + "/" + i + "I.vrs");
|
||||||
|
}
|
||||||
|
vrsPath = boardIdPath + "/" + i + "I.vrs";
|
||||||
|
|
||||||
|
//读数据
|
||||||
|
if (QFile(vrsPath).exists()) {
|
||||||
|
bool hasVerify = false;
|
||||||
|
item = new QTreeWidgetItem(dateItem);
|
||||||
|
|
||||||
|
QJsonObject obj;
|
||||||
|
JSONDocUtil::getInstance().readJSONDoc(vrsPath, obj);
|
||||||
|
QString job = obj.value("Job").toString();
|
||||||
|
QString layer = obj.value("Layer").toString();
|
||||||
|
int count = obj.value("Count").toInt();
|
||||||
|
|
||||||
|
item->setText(0, job + "/" + layer);
|
||||||
|
item->setText(1, boardId);
|
||||||
|
item->setText(2, vrsPath.mid(vrsPath.size() - 6, 1));
|
||||||
|
|
||||||
|
//读有效缺陷数
|
||||||
|
int validSum = getValid(obj , hasVerify);
|
||||||
|
item->setText(3, QString::number(validSum) + "/" + QString::number(count));
|
||||||
|
if (hasVerify) {
|
||||||
|
QBrush brush = QBrush(QColor("#C3FFC3"));
|
||||||
|
item->setBackground(0, brush);
|
||||||
|
item->setBackground(1, brush);
|
||||||
|
item->setBackground(2, brush);
|
||||||
|
item->setBackground(3, brush);
|
||||||
|
}
|
||||||
|
m_boardItemList.push_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::toJson(QJsonObject& yearJson, QString& path) {
|
||||||
|
QDir rootDir(path);
|
||||||
|
QStringList dateList = rootDir.entryList(QDir::NoDotAndDotDot | QDir::AllDirs, QDir::Time);
|
||||||
|
|
||||||
|
for (QString dateStr : dateList) {
|
||||||
|
QString yearStr = dateStr.mid(0, 4);
|
||||||
|
QString monthStr = dateStr.mid(0, 7);
|
||||||
|
|
||||||
|
if (!yearJson.contains(yearStr)) {
|
||||||
|
yearJson.insert(yearStr, QJsonObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject monthJson = yearJson.value(yearStr).toObject();
|
||||||
|
if (!monthJson.contains(monthStr)) {
|
||||||
|
monthJson.insert(monthStr, QJsonObject());
|
||||||
|
yearJson.insert(yearStr, monthJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonArray dateArr = monthJson.value(monthStr).toArray();
|
||||||
|
dateArr.append(dateStr);
|
||||||
|
monthJson.insert(monthStr, dateArr);
|
||||||
|
yearJson.insert(yearStr, monthJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::clear() {
|
||||||
|
m_curDefectLbl.setText(" 0 : :0/0");
|
||||||
|
QLayoutItem* item;
|
||||||
|
while ((item = m_grdLt.takeAt(0)) != nullptr) {
|
||||||
|
QWidget* widget = item->widget();
|
||||||
|
widget->setParent(NULL);
|
||||||
|
delete widget;
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::slot_treeWgtCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous) {
|
||||||
|
//清理
|
||||||
|
clear();
|
||||||
|
|
||||||
|
if (current == nullptr || current->columnCount() == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showDefectCountCmbIndexChanged();
|
||||||
|
|
||||||
|
//填充
|
||||||
|
QString dateStr = current->parent()->text(0);
|
||||||
|
QString jobLayer = current->text(0);
|
||||||
|
QString boardId = current->text(1);
|
||||||
|
QString ab = current->text(2);
|
||||||
|
int count = current->text(3).split("/").at(1).toInt();
|
||||||
|
|
||||||
|
m_dirPath = "D:/PCBDataset/Defect/fengming/AOI_DEFECT/" + dateStr + "/" + boardId + "/";
|
||||||
|
m_ab = ab;
|
||||||
|
m_curDefectLbl.setText(boardId + ":" + ab + ":" + current->text(3));
|
||||||
|
|
||||||
|
//缓存 Json
|
||||||
|
QString fileName = m_dirPath + m_ab + "I.vrs";
|
||||||
|
if (QFile(fileName).exists()) {
|
||||||
|
JSONDocUtil::getInstance().readJSONDoc(fileName, m_vrsJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonArray arr = m_vrsJson.value("Defectx").toArray();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
DefectViewCustom* defectItem = new DefectViewCustom();
|
||||||
|
defectItem->m_preVerifyWgt = this;
|
||||||
|
defectItem->setParent(this);
|
||||||
|
QJsonObject obj = arr.at(i).toObject();
|
||||||
|
bool isValid = true;
|
||||||
|
if (obj.contains("AIresult") && obj.value("AIresult") == 0) {
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
int defectId = i + 1;
|
||||||
|
int defectType = obj.value("Code").toDouble();
|
||||||
|
double x = obj.value("X").toDouble();
|
||||||
|
double y = obj.value("Y").toDouble();
|
||||||
|
|
||||||
|
QString samplePath = "D:/PCBDataset/Reference/" + jobLayer + "\\Learn\\panel_image.png";
|
||||||
|
if (!QPixmapCache::find(jobLayer, &m_samplePxmp)) {
|
||||||
|
m_samplePxmp.load(samplePath, nullptr, Qt::NoFormatConversion);
|
||||||
|
QPixmapCache::insert(jobLayer, m_samplePxmp);
|
||||||
|
}
|
||||||
|
bool containSample = m_showCamChk.isChecked();
|
||||||
|
defectItem->load(m_dirPath + m_ab + QString::number(defectId) + ".jpg", defectId, isValid, x, y, jobLayer, m_samplePxmp, defectType, m_rowHeight, containSample);
|
||||||
|
if (m_colCount == 2) {
|
||||||
|
defectItem->scale(1.8, 1.8);
|
||||||
|
}
|
||||||
|
else if (m_colCount == 3) {
|
||||||
|
defectItem->scale(1.6, 1.6);
|
||||||
|
}
|
||||||
|
else if (m_colCount == 4) {
|
||||||
|
defectItem->scale(0.9, 0.9);
|
||||||
|
}
|
||||||
|
else if (m_colCount == 5) {
|
||||||
|
defectItem->scale(0.9, 0.9);
|
||||||
|
}
|
||||||
|
m_grdLt.addWidget(defectItem, i / m_colCount, i % m_colCount);
|
||||||
|
|
||||||
|
m_grdScr.verticalScrollBar()->setSingleStep(m_grdScr.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_grdScr.verticalScrollBar()->setSliderPosition(0);
|
||||||
|
this->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
//1.添加 -1.删除
|
||||||
|
void PreVerifyWidget::updateOne(QString defectId, int action) {
|
||||||
|
int ix = defectId.toInt() - 1;
|
||||||
|
QJsonArray arr = m_vrsJson.value("Defectx").toArray();
|
||||||
|
QJsonObject obj = arr.at(ix).toObject();
|
||||||
|
|
||||||
|
if (action == 1) {
|
||||||
|
obj.insert("AIresult", 1);
|
||||||
|
arr.replace(ix, obj);
|
||||||
|
}
|
||||||
|
else if (action == -1) {
|
||||||
|
obj.insert("AIresult", 0);
|
||||||
|
int size = arr.size();
|
||||||
|
arr.replace(ix, obj);
|
||||||
|
}
|
||||||
|
m_vrsJson.insert("Defectx", arr);
|
||||||
|
|
||||||
|
//写回
|
||||||
|
QString vrsPath = m_dirPath + m_ab + "I.vrs";
|
||||||
|
JSONDocUtil::getInstance().writeJSONDoc(vrsPath, m_vrsJson);
|
||||||
|
|
||||||
|
bool hasVerify = true;
|
||||||
|
int validSum = getValid(m_vrsJson, hasVerify);
|
||||||
|
QString totalCount = m_treeWgt.currentItem()->text(3).split("/").at(1);
|
||||||
|
m_treeWgt.currentItem()->setText(3, QString::number(validSum) + "/" + totalCount);
|
||||||
|
|
||||||
|
QBrush brush = QBrush(QColor("#C3FFC3"));
|
||||||
|
m_treeWgt.currentItem()->setBackground(0, brush);
|
||||||
|
m_treeWgt.currentItem()->setBackground(1, brush);
|
||||||
|
m_treeWgt.currentItem()->setBackground(2, brush);
|
||||||
|
m_treeWgt.currentItem()->setBackground(3, brush);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PreVerifyWidget::getValid(QJsonObject& obj, bool& hasVerify){
|
||||||
|
QJsonArray arr = obj.value("Defectx").toArray();
|
||||||
|
int validSum = arr.size();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
QJsonObject arrItem = arr.at(i).toObject();
|
||||||
|
if (!hasVerify && arrItem.contains("AIresult")) {
|
||||||
|
hasVerify = true;
|
||||||
|
}
|
||||||
|
if (arrItem.contains("AIresult") && arrItem.value("AIresult").toInt() == 0) {
|
||||||
|
validSum--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validSum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::filter() {
|
||||||
|
QString boardId = m_boardIdEdt.text();
|
||||||
|
QString job = m_jobEdt.text();
|
||||||
|
QString layer = m_layerEdt.text();
|
||||||
|
//QString year = m_spinY.text();
|
||||||
|
//QString month = m_spinM.text();
|
||||||
|
//QString date = m_spinD.text();
|
||||||
|
QString year;
|
||||||
|
QString month;
|
||||||
|
QString date;
|
||||||
|
QString dd = m_dateCmb.currentText();
|
||||||
|
if (!dd.isEmpty()) {
|
||||||
|
QStringList ll = dd.split("-");
|
||||||
|
year = ll.at(0);
|
||||||
|
month = ll.at(1);
|
||||||
|
date = ll.at(2);
|
||||||
|
}
|
||||||
|
if (month.size() == 1) {
|
||||||
|
month = "0" + month;
|
||||||
|
}
|
||||||
|
if (date.size() == 1) {
|
||||||
|
date = "0" + date;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = m_treeWgt.topLevelItemCount();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
QTreeWidgetItem* yearItem = m_treeWgt.topLevelItem(i);//year
|
||||||
|
if (!year.isEmpty() && !yearItem->text(0).contains(year)) {
|
||||||
|
yearItem->setHidden(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
yearItem->setHidden(false);
|
||||||
|
int count2 = yearItem->childCount();
|
||||||
|
bool yearIsNull = true;
|
||||||
|
for (int j = 0; j < count2; j++) {
|
||||||
|
QTreeWidgetItem* monthItem = yearItem->child(j);
|
||||||
|
if (!month.isEmpty() && !monthItem->text(0).endsWith(month)) {
|
||||||
|
monthItem->setHidden(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
monthItem->setHidden(false);
|
||||||
|
int count3 = monthItem->childCount();
|
||||||
|
bool monthIsNull = true;
|
||||||
|
for (int k = 0; k < count3; k++) {
|
||||||
|
QTreeWidgetItem* dateItem = monthItem->child(k);
|
||||||
|
if (!date.isEmpty() && !dateItem->text(0).endsWith(date)) {
|
||||||
|
dateItem->setHidden(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dateItem->setHidden(false);
|
||||||
|
bool dateIsNull = true;
|
||||||
|
for (int g = 0; g < dateItem->childCount(); g++) {
|
||||||
|
QTreeWidgetItem* boardItem = dateItem->child(g);
|
||||||
|
if(!boardId.isEmpty()){
|
||||||
|
if (boardItem->text(1).contains(boardId)) {
|
||||||
|
boardItem->setHidden(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
boardItem->setHidden(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
boardItem->setHidden(false);
|
||||||
|
}
|
||||||
|
if (!job.isEmpty()) {
|
||||||
|
if (boardItem->text(0).contains(job)) {
|
||||||
|
boardItem->setHidden(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
boardItem->setHidden(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
boardItem->setHidden(false);
|
||||||
|
}
|
||||||
|
if (!layer.isEmpty()) {
|
||||||
|
if (boardItem->text(0).contains(layer)) {
|
||||||
|
boardItem->setHidden(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
boardItem->setHidden(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
boardItem->setHidden(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!boardItem->isHidden()) {
|
||||||
|
dateIsNull = false;
|
||||||
|
monthIsNull = false;
|
||||||
|
yearIsNull = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dateIsNull) {
|
||||||
|
dateItem->setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (monthIsNull) {
|
||||||
|
monthItem->setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (yearIsNull) {
|
||||||
|
yearItem->setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_treeWgt.expandAll();
|
||||||
|
m_treeWgt.setCurrentItem(nullptr);
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::slot_lastBoardBtnPressed() {
|
||||||
|
QTreeWidgetItem* cur = m_treeWgt.currentItem();
|
||||||
|
if (cur == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int ix = m_boardItemList.indexOf(cur);
|
||||||
|
while (ix - 1 >= 0) {
|
||||||
|
QTreeWidgetItem* lastItem = m_boardItemList.at(ix - 1);
|
||||||
|
if (!lastItem->isHidden() && !lastItem->parent()->isHidden()
|
||||||
|
&& !lastItem->parent()->parent()->isHidden()
|
||||||
|
&& !lastItem->parent()->parent()->parent()->isHidden()) {
|
||||||
|
m_treeWgt.setCurrentItem(lastItem);
|
||||||
|
slot_treeWgtCurrentItemChanged(lastItem, cur);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ix--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::slot_nextBoardBtnPressed() {
|
||||||
|
QTreeWidgetItem* cur = m_treeWgt.currentItem();
|
||||||
|
if (cur == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int ix = m_boardItemList.indexOf(cur);
|
||||||
|
while (ix + 1 < m_boardItemList.size()) {
|
||||||
|
QTreeWidgetItem* nextItem = m_boardItemList.at(ix + 1);
|
||||||
|
if (!nextItem->isHidden() && !nextItem->parent()->isHidden()
|
||||||
|
&& !nextItem->parent()->parent()->isHidden()
|
||||||
|
&& !nextItem->parent()->parent()->parent()->isHidden()) {
|
||||||
|
m_treeWgt.setCurrentItem(nextItem);
|
||||||
|
slot_treeWgtCurrentItemChanged(nextItem, cur);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ix++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::slot_lastDefectBtnPressed() {
|
||||||
|
if (m_treeWgt.currentItem() == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QScrollBar* bar = m_grdScr.verticalScrollBar();
|
||||||
|
int sliderHeight = bar->singleStep();
|
||||||
|
int newPosition = bar->sliderPosition() - sliderHeight;
|
||||||
|
if (bar->sliderPosition() == 0) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle("提示");
|
||||||
|
msgBox.setText("已经是第一页了!");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||||
|
QPushButton* nextButton = new QPushButton("进入上一片");
|
||||||
|
msgBox.addButton(nextButton, QMessageBox::ActionRole);
|
||||||
|
int ret = msgBox.exec();
|
||||||
|
if (msgBox.clickedButton() == nextButton) {
|
||||||
|
slot_lastBoardBtnPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (newPosition >= 0) {
|
||||||
|
bar->setSliderPosition(newPosition);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bar->setSliderPosition(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::slot_nextDefectBtnPressed() {
|
||||||
|
if (m_treeWgt.currentItem() == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QScrollBar* bar = m_grdScr.verticalScrollBar();
|
||||||
|
int sliderHeight = bar->singleStep();
|
||||||
|
int newPosition = bar->sliderPosition() + sliderHeight;
|
||||||
|
if (bar->sliderPosition() == bar->maximum()) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle("提示");
|
||||||
|
msgBox.setText("已经是最后一页了!");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||||
|
QPushButton* nextButton = new QPushButton("进入下一片");
|
||||||
|
msgBox.addButton(nextButton, QMessageBox::ActionRole);
|
||||||
|
int ret = msgBox.exec();
|
||||||
|
if (msgBox.clickedButton() == nextButton) {
|
||||||
|
slot_nextBoardBtnPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (newPosition <= bar->maximum()) {
|
||||||
|
bar->setSliderPosition(newPosition);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bar->setSliderPosition(bar->maximum());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::keyPressEvent(QKeyEvent* event) {
|
||||||
|
switch (event->key()) {
|
||||||
|
case Qt::Key_Left:
|
||||||
|
slot_lastBoardBtnPressed();
|
||||||
|
break;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
slot_nextBoardBtnPressed();
|
||||||
|
break;
|
||||||
|
case Qt::Key_Up:
|
||||||
|
slot_lastDefectBtnPressed();
|
||||||
|
break;
|
||||||
|
case Qt::Key_Down:
|
||||||
|
slot_nextDefectBtnPressed();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//QWidget::keyPressEvent(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreVerifyWidget::slot_winStateChangeEvent() {
|
||||||
|
slot_treeWgtCurrentItemChanged(m_treeWgt.currentItem(), nullptr);
|
||||||
|
}
|
110
PreVerify/PreVerifyWidget.h
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <qwidget.h>
|
||||||
|
#include "QHBoxLayout"
|
||||||
|
#include "QTreeWidget"
|
||||||
|
#include "QTableWidget"
|
||||||
|
#include "QGridLayout"
|
||||||
|
#include "qscrollarea.h"
|
||||||
|
#include "QJsonObject"
|
||||||
|
#include "QVBoxLayout"
|
||||||
|
#include "QDateEdit"
|
||||||
|
#include "QLineEdit"
|
||||||
|
#include "QPushButton"
|
||||||
|
#include "QLabel"
|
||||||
|
#include "QCheckbox"
|
||||||
|
#include "QComboBox"
|
||||||
|
#include "qspinbox.h"
|
||||||
|
#include "ScrollAreaCustom.h"
|
||||||
|
#include "qmutex.h"
|
||||||
|
|
||||||
|
|
||||||
|
class PreVerifyWidget : public QWidget {
|
||||||
|
|
||||||
|
public:
|
||||||
|
PreVerifyWidget(QWidget* parent = nullptr);
|
||||||
|
~PreVerifyWidget();
|
||||||
|
void setUi();
|
||||||
|
void setConnection();
|
||||||
|
void load();
|
||||||
|
void updateOne(QString defectId, int action);
|
||||||
|
QString defectId2Desc(int defectId);
|
||||||
|
void filter();
|
||||||
|
void showDefectCountCmbIndexChanged();
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void loadTreeWgt();
|
||||||
|
int getValid(QJsonObject& obj, bool& hasVerify);
|
||||||
|
void toJson(QJsonObject& yearJson, QString& path);
|
||||||
|
void readDefectTypesDesc();
|
||||||
|
void clear();
|
||||||
|
void loadDate();
|
||||||
|
|
||||||
|
QHBoxLayout m_lt;
|
||||||
|
QGridLayout m_leftLt;
|
||||||
|
QVBoxLayout m_rightLt;
|
||||||
|
QTreeWidget m_treeWgt;
|
||||||
|
ScrollAreaCustom m_grdScr;
|
||||||
|
QWidget m_grdWgt;
|
||||||
|
QGridLayout m_grdLt;
|
||||||
|
|
||||||
|
QLabel label1;
|
||||||
|
QLabel label11;
|
||||||
|
QLabel label2;
|
||||||
|
QLabel label3;
|
||||||
|
QLabel label4;
|
||||||
|
QDateEdit m_dateEdt;
|
||||||
|
QPushButton m_yearClearBtn;
|
||||||
|
QPushButton m_monthClearBtn;
|
||||||
|
QPushButton m_dateClearBtn;
|
||||||
|
QLineEdit m_boardIdEdt;
|
||||||
|
QLineEdit m_jobEdt;
|
||||||
|
QLineEdit m_layerEdt;
|
||||||
|
QLabel labelY;
|
||||||
|
QLabel labelM;
|
||||||
|
QLabel labelD;
|
||||||
|
QSpinBox m_spinY;
|
||||||
|
QSpinBox m_spinM;
|
||||||
|
QSpinBox m_spinD;
|
||||||
|
QHBoxLayout m_dateLt;
|
||||||
|
QComboBox m_dateCmb;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QHBoxLayout m_pageBtnLt;
|
||||||
|
QPushButton m_lastBoardBtn;
|
||||||
|
QPushButton m_lastDefectBtn;
|
||||||
|
QPushButton m_nextBoardBtn;
|
||||||
|
QPushButton m_nextDefectBtn;
|
||||||
|
QLabel m_curDefectLbl;
|
||||||
|
QCheckBox m_showCamChk;
|
||||||
|
QLabel m_showDefectCountLbl;
|
||||||
|
QComboBox m_showDefectCountCmb;
|
||||||
|
|
||||||
|
|
||||||
|
QString m_dirPath;
|
||||||
|
QJsonObject m_vrsJson;
|
||||||
|
QStringList m_removeList;
|
||||||
|
QString m_ab;
|
||||||
|
QJsonObject m_defectTypesDescJson;
|
||||||
|
QPixmap m_samplePxmp;
|
||||||
|
int m_rowCount = 2;
|
||||||
|
int m_colCount = 5;
|
||||||
|
int m_rowHeight = -1;
|
||||||
|
QList<QTreeWidgetItem*> m_boardItemList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slot_treeWgtCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||||
|
void slot_lastBoardBtnPressed();
|
||||||
|
void slot_lastDefectBtnPressed();
|
||||||
|
void slot_nextBoardBtnPressed();
|
||||||
|
void slot_nextDefectBtnPressed();
|
||||||
|
void slot_winStateChangeEvent();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
7
PreVerify/ScrollAreaCustom.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "ScrollAreaCustom.h"
|
||||||
|
#include "PreVerifyWidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
void ScrollAreaCustom::keyPressEvent(QKeyEvent* e) {
|
||||||
|
((PreVerifyWidget*)this->parent())->keyPressEvent(e);
|
||||||
|
}
|
12
PreVerify/ScrollAreaCustom.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "QWidget"
|
||||||
|
#include "QScrollArea"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class ScrollAreaCustom : public QScrollArea {
|
||||||
|
|
||||||
|
public:
|
||||||
|
void keyPressEvent(QKeyEvent* e) override;
|
||||||
|
};
|
||||||
|
|
70
PreVerify/main.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
#include "MainWidget.h"
|
||||||
|
#include <QSharedMemory>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include "QList"
|
||||||
|
#include "QScreen"
|
||||||
|
#include "QGuiApplication"
|
||||||
|
#include <windows.h>
|
||||||
|
#include <dbghelp.h>
|
||||||
|
#include "XDongleVerifierWorker.h"
|
||||||
|
#include "QDir"
|
||||||
|
#include "QDateTime"
|
||||||
|
|
||||||
|
|
||||||
|
#pragma comment(lib, "Dbghelp.lib")
|
||||||
|
LONG WINAPI exceptionCallback(struct _EXCEPTION_POINTERS* exceptionInfo);
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
SetUnhandledExceptionFilter(exceptionCallback);
|
||||||
|
|
||||||
|
|
||||||
|
MainWidget* mainWidget = new MainWidget();
|
||||||
|
mainWidget->load();
|
||||||
|
mainWidget->show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int rc = a.exec();
|
||||||
|
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static LONG WINAPI exceptionCallback(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||||
|
QCoreApplication* app = QCoreApplication::instance();
|
||||||
|
|
||||||
|
QString savePath = app->applicationDirPath() + "/dump/";
|
||||||
|
qDebug() << "save path :" << savePath;
|
||||||
|
QDir dir(savePath);
|
||||||
|
if (!dir.exists() && !dir.mkpath(savePath)) {
|
||||||
|
app->exit(E_UNEXPECTED);
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
||||||
|
savePath.append("PreVerify_");
|
||||||
|
savePath.append(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
||||||
|
savePath.append(".dmp");
|
||||||
|
|
||||||
|
HANDLE dump = CreateFileW(savePath.toStdWString().c_str(), GENERIC_WRITE,
|
||||||
|
0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
if (INVALID_HANDLE_VALUE == dump) {
|
||||||
|
app->exit(E_UNEXPECTED);
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
||||||
|
|
||||||
|
MINIDUMP_EXCEPTION_INFORMATION miniDumpExceptionInfo;
|
||||||
|
miniDumpExceptionInfo.ExceptionPointers = exceptionInfo;
|
||||||
|
miniDumpExceptionInfo.ThreadId = GetCurrentThreadId();
|
||||||
|
miniDumpExceptionInfo.ClientPointers = TRUE;
|
||||||
|
DWORD idProcess = GetCurrentProcessId();
|
||||||
|
MiniDumpWriteDump(GetCurrentProcess(), idProcess, dump,
|
||||||
|
MiniDumpNormal, &miniDumpExceptionInfo, NULL, NULL);
|
||||||
|
|
||||||
|
CloseHandle(dump);
|
||||||
|
|
||||||
|
app->exit(E_UNEXPECTED);
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
BIN
PreVerify/res/ico/dateClear.png
Normal file
After Width: | Height: | Size: 326 B |
BIN
PreVerify/res/ico/lastBoard.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
PreVerify/res/ico/lastDefect.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
PreVerify/res/ico/nextBoard.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
PreVerify/res/ico/nextDefect.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
PreVerify/res/png/analysis.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
PreVerify/res/png/browse.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
PreVerify/res/png/create.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
PreVerify/res/png/debug.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
PreVerify/res/png/defect.png
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
PreVerify/res/png/filter.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
PreVerify/res/png/filter_cancel.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
PreVerify/res/png/logo.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
PreVerify/res/png/open.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
PreVerify/res/png/pcb.png
Normal file
After Width: | Height: | Size: 109 KiB |
BIN
PreVerify/res/png/pcbThum.png
Normal file
After Width: | Height: | Size: 197 KiB |
BIN
PreVerify/res/png/pcbbin.png
Normal file
After Width: | Height: | Size: 145 KiB |
BIN
PreVerify/res/png/pcbscan.png
Normal file
After Width: | Height: | Size: 161 KiB |
BIN
PreVerify/res/png/settings.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
PreVerify/res/png/status.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
PreVerify/res/png/向右旋转.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
PreVerify/res/png/向左旋转.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
PreVerify/res/png/框选.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
PreVerify/res/png/正反对调.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
PreVerify/res/png/测量距离.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
228
QtYaml/QtYaml.cpp
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
#include "QtYaml.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "yaml-cpp/yaml.h"
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <iosfwd>
|
||||||
|
|
||||||
|
|
||||||
|
YAML::Node QtYaml::LoadFile2(QString fileName) {
|
||||||
|
YAML::Node node;
|
||||||
|
QFile file(fileName);
|
||||||
|
QFileInfo fileinfo(file);
|
||||||
|
|
||||||
|
if (!fileinfo.exists()) {
|
||||||
|
QString strLog = QString("YAML: this file not exist(%1).").
|
||||||
|
arg(fileName);
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fileinfo.isFile()) {
|
||||||
|
QString strLog = QString("YAML: this path not a file(%1).").
|
||||||
|
arg(fileName);
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileinfo.size() == 0) {
|
||||||
|
QString strLog = QString("YAML: file content is empty(%1).").
|
||||||
|
arg(fileName);
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
bool isOpen = file.open(QIODevice::ReadOnly);
|
||||||
|
file.close();
|
||||||
|
if (!isOpen) throw file.error();
|
||||||
|
}
|
||||||
|
catch (const QFileDevice::FileError& err) {
|
||||||
|
QString strLog = QString("YAML: file could not be opened(%1):%2.").
|
||||||
|
arg(fileName).
|
||||||
|
arg(static_cast<int>(err));
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_fileName = fileName;
|
||||||
|
|
||||||
|
try {
|
||||||
|
node = YAML::LoadAllFromFile(fileName.toStdString());
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception& err) {
|
||||||
|
QString strLog = QString(err.what()).replace("yaml-cpp", "YAML");
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtYaml::LoadFile(QString& fileName)
|
||||||
|
{
|
||||||
|
m_node = YAML::LoadFile(fileName.toStdString());
|
||||||
|
|
||||||
|
QFile file(fileName);
|
||||||
|
QFileInfo fileinfo(file);
|
||||||
|
|
||||||
|
if (!fileinfo.exists())
|
||||||
|
{
|
||||||
|
QString strLog = QString("YAML: this file not exist(%1).").
|
||||||
|
arg(fileName);
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fileinfo.isFile())
|
||||||
|
{
|
||||||
|
QString strLog = QString("YAML: this path not a file(%1).").
|
||||||
|
arg(fileName);
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileinfo.size() == 0)
|
||||||
|
{
|
||||||
|
QString strLog = QString("YAML: file content is empty(%1).").
|
||||||
|
arg(fileName);
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool isOpen = file.open(QIODevice::ReadOnly);
|
||||||
|
file.close();
|
||||||
|
if (!isOpen) throw file.error();
|
||||||
|
}
|
||||||
|
catch (const QFileDevice::FileError& err)
|
||||||
|
{
|
||||||
|
QString strLog = QString("YAML: file could not be opened(%1):%2.").
|
||||||
|
arg(fileName).
|
||||||
|
arg(static_cast<int>(err));
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_fileName = fileName;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_node = YAML::LoadFile(fileName.toStdString());
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception& err)
|
||||||
|
{
|
||||||
|
QString strLog = QString(err.what()).replace("yaml-cpp", "YAML");
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtYaml::LoadString(QString& data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_node = YAML::Load(data.toStdString());
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception& err)
|
||||||
|
{
|
||||||
|
QString strLog = QString(err.what()).replace("yaml-cpp", "YAML");
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtYaml::GetString(std::string sec, std::string key, std::string& s)
|
||||||
|
{
|
||||||
|
if (!m_node[sec][key].IsScalar())
|
||||||
|
return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
s = m_node[sec][key].as<std::string>();
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception& err)
|
||||||
|
{
|
||||||
|
QString strLog = QString(err.what()).replace("yaml-cpp", "YAML");
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool QtYaml::GetBool(std::string sec, std::string key, bool& b)
|
||||||
|
{
|
||||||
|
if (!m_node[sec][key].IsScalar())
|
||||||
|
return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
b = m_node[sec][key].as<bool>();
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception& err)
|
||||||
|
{
|
||||||
|
QString strLog = QString(err.what()).replace("yaml-cpp", "YAML");
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool QtYaml::GetInt(std::string sec, std::string key, int& n)
|
||||||
|
{
|
||||||
|
if (!m_node[sec][key].IsScalar())
|
||||||
|
return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
n = m_node[sec][key].as<int>();
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception& err)
|
||||||
|
{
|
||||||
|
QString strLog = QString(err.what()).replace("yaml-cpp", "YAML");
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool QtYaml::GetDouble(std::string sec, std::string key, double& f)
|
||||||
|
{
|
||||||
|
if (!m_node[sec][key].IsScalar())
|
||||||
|
return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
f = m_node[sec][key].as<double>();
|
||||||
|
}
|
||||||
|
catch (const YAML::Exception& err)
|
||||||
|
{
|
||||||
|
QString strLog = QString(err.what()).replace("yaml-cpp", "YAML");
|
||||||
|
l4qDebug(strLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void split(std::vector<std::string>& strings, std::string data) {
|
||||||
|
std::istringstream f(data);
|
||||||
|
std::string s;
|
||||||
|
char sep = ',';
|
||||||
|
while (getline(f, s, sep)) {
|
||||||
|
strings.emplace_back(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void split(std::vector<int>& ints, std::string data) {
|
||||||
|
std::istringstream f(data);
|
||||||
|
std::string s;
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
char sep = ',';
|
||||||
|
while (getline(f, s, sep)) {
|
||||||
|
strings.emplace_back(s);
|
||||||
|
}
|
||||||
|
std::vector<std::string>::iterator it = strings.begin();
|
||||||
|
for (it; it != strings.end(); it++) {
|
||||||
|
QString str(it->c_str());
|
||||||
|
ints.push_back(str.toInt());
|
||||||
|
}
|
||||||
|
}
|
34
QtYaml/QtYaml.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <yaml-cpp/yaml.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
class QtYaml : public QObject
|
||||||
|
{
|
||||||
|
LOG4QT_DECLARE_QCLASS_LOGGER
|
||||||
|
public:
|
||||||
|
QtYaml() {}
|
||||||
|
~QtYaml() {}
|
||||||
|
YAML::Node LoadFile2(QString fileName);
|
||||||
|
bool LoadFile(QString& fileName);
|
||||||
|
bool LoadString(QString& data);
|
||||||
|
bool GetString(std::string sec, std::string key, std::string& s);
|
||||||
|
bool GetBool(std::string sec, std::string key, bool& b);
|
||||||
|
bool GetInt(std::string sec, std::string key, int& n);
|
||||||
|
bool GetDouble(std::string sec, std::string key, double& f);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_fileName;
|
||||||
|
YAML::Node m_node;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QtYaml(QtYaml const&) = delete;
|
||||||
|
void operator=(QtYaml const&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void split(std::vector<std::string>& strings, std::string data);
|
||||||
|
void split(std::vector<int>& ints, std::string data);
|
25
QtYaml/QtYaml.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.9.34728.123
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtYaml", "QtYaml.vcxproj", "{4434DF84-4E42-4E30-8F2A-A04BE89705A3}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{4434DF84-4E42-4E30-8F2A-A04BE89705A3}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {6E737AD7-664C-4F76-9B4A-C4E3A90E0891}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
144
QtYaml/QtYaml.vcxproj
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{4434DF84-4E42-4E30-8F2A-A04BE89705A3}</ProjectGuid>
|
||||||
|
<Keyword>QtVS_v304</Keyword>
|
||||||
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0.22621.0</WindowsTargetPlatformVersion>
|
||||||
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.22621.0</WindowsTargetPlatformVersion>
|
||||||
|
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||||
|
<ProjectName>QtYaml</ProjectName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
||||||
|
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||||
|
<QtInstall>QT6.5</QtInstall>
|
||||||
|
<QtModules>core</QtModules>
|
||||||
|
<QtBuildConfig>debug</QtBuildConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||||
|
<QtInstall>QT6.5</QtInstall>
|
||||||
|
<QtModules>core</QtModules>
|
||||||
|
<QtBuildConfig>release</QtBuildConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||||
|
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||||
|
</Target>
|
||||||
|
<ImportGroup Label="ExtensionSettings" />
|
||||||
|
<ImportGroup Label="Shared" />
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||||
|
<Import Project="..\lib\yaml\yaml.props" />
|
||||||
|
<Import Project="..\lib\log4Qt\log4qt.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||||
|
<Import Project="..\lib\yaml\yaml.props" />
|
||||||
|
<Import Project="..\lib\log4Qt\log4qt.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||||
|
<LinkIncremental />
|
||||||
|
<TargetName>$(ProjectName)d</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Link>
|
||||||
|
<AdditionalLibraryDirectories>$(OutDir);</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
<ClCompile>
|
||||||
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(Qt_INCLUDEPATH_);$(SolutionDir)logger;</AdditionalIncludeDirectories>
|
||||||
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
</ClCompile>
|
||||||
|
<Lib>
|
||||||
|
<AdditionalDependencies>loggerd.lib</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||||
|
</Lib>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Link>
|
||||||
|
<AdditionalLibraryDirectories>$(OutDir);</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
<ClCompile>
|
||||||
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(Qt_INCLUDEPATH_);$(SolutionDir)logger;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Lib>
|
||||||
|
<AdditionalDependencies>logger.lib</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||||
|
</Lib>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
<ClCompile>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<PreprocessorDefinitions>UNICODE;_UNICODE;LOG4QT_VERSION_STR="1.6.0";LOG4QT_VERSION_MAJOR=1;LOG4QT_VERSION_MINOR=6;LOG4QT_VERSION_PATCH=0;YAML_CPP_STATIC_DEFINE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<WarningLevel>Level1</WarningLevel>
|
||||||
|
<SDLCheck>
|
||||||
|
</SDLCheck>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||||
|
<ClCompile>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<PreprocessorDefinitions>UNICODE;_UNICODE;LOG4QT_VERSION_STR="1.6.0";LOG4QT_VERSION_MAJOR=1;LOG4QT_VERSION_MINOR=6;LOG4QT_VERSION_PATCH=0;YAML_CPP_STATIC_DEFINE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<WarningLevel>Level1</WarningLevel>
|
||||||
|
<SDLCheck>
|
||||||
|
</SDLCheck>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="QtYaml.h" />
|
||||||
|
<ClCompile Include="QtYaml.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||||
|
<Import Project="$(QtMsBuild)\qt.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
35
QtYaml/QtYaml.vcxproj.filters
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Form Files">
|
||||||
|
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||||
|
<Extensions>ui</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Translation Files">
|
||||||
|
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||||
|
<Extensions>ts</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="QtYaml.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="QtYaml.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
BIN
lib/3dparty/XCrypto.dll
Normal file
BIN
lib/3dparty/XFilelog.dll
Normal file
BIN
lib/3dparty/XFilelogd.dll
Normal file
BIN
lib/3dparty/XLog2.dll
Normal file
BIN
lib/3dparty/libapr-1.dll
Normal file
BIN
lib/3dparty/libaprutil-1.dll
Normal file
BIN
lib/3dparty/libexpat.dll
Normal file
BIN
lib/3dparty/libtcmalloc_minimal.dll
Normal file
BIN
lib/3dparty/log4cxx.dll
Normal file
6
lib/ChristofidesTSP/ChristofidesTSP.props
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(PlatformToolset)|$(Platform)'=='v143|x64'">
|
||||||
|
<IncludePath>$(SolutionDir)lib\ChristofidesTSP\include;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
203
lib/ChristofidesTSP/include/ChristofidesTSP/ChristofidesTSP.h
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
#ifndef CHRISTOFIDES_TSP_H
|
||||||
|
#define CHRISTOFIDES_TSP_H
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <functional>
|
||||||
|
#include <cmath>
|
||||||
|
#include <limits>
|
||||||
|
#include <queue>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
|
namespace TSPSolver {
|
||||||
|
|
||||||
|
struct Point {
|
||||||
|
double x, y;
|
||||||
|
static double DistanceL2(const Point& p1, const Point& p2);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::vector<size_t> ChristofidesTSP(const std::vector<T>& points, std::function<Point(const T&)> GetPointFunc);
|
||||||
|
|
||||||
|
// Ensure that the type T can be converted to a Point
|
||||||
|
template <typename T>
|
||||||
|
concept PointConvertible = requires(T p, std::function<Point(const T&)> GetPointFunc) {
|
||||||
|
{ GetPointFunc(p) } -> std::convertible_to<Point>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Edge {
|
||||||
|
size_t u, v;
|
||||||
|
double weight;
|
||||||
|
bool operator<(const Edge& other) const {
|
||||||
|
return weight > other.weight; // For min-heap
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using Graph = std::vector<std::vector<std::pair<size_t, double>>>;
|
||||||
|
|
||||||
|
double Point::DistanceL2(const Point& p1, const Point& p2) {
|
||||||
|
return std::sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
double DistanceL2(const T& p1, const T& p2, std::function<Point(const T&)> GetPointFunc) {
|
||||||
|
Point pt1 = GetPointFunc(p1);
|
||||||
|
Point pt2 = GetPointFunc(p2);
|
||||||
|
return Point::DistanceL2(pt1, pt2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddEdge(Graph& graph, size_t u, size_t v, double weight) {
|
||||||
|
graph[u].emplace_back(v, weight);
|
||||||
|
graph[v].emplace_back(u, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <PointConvertible T>
|
||||||
|
std::vector<Edge> PrimMST(const std::vector<T>& points, std::function<Point(const T&)> GetPointFunc) {
|
||||||
|
size_t n = points.size();
|
||||||
|
std::priority_queue<Edge> pq;
|
||||||
|
std::vector<bool> inMST(n, false);
|
||||||
|
std::vector<Edge> mstEdges;
|
||||||
|
|
||||||
|
inMST[0] = true;
|
||||||
|
for (size_t i = 1; i < n; ++i) {
|
||||||
|
pq.push({0, i, DistanceL2(points[0], points[i], GetPointFunc)});
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!pq.empty()) {
|
||||||
|
Edge edge = pq.top();
|
||||||
|
pq.pop();
|
||||||
|
if (inMST[edge.v]) continue;
|
||||||
|
inMST[edge.v] = true;
|
||||||
|
mstEdges.push_back(edge);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < n; ++i) {
|
||||||
|
if (!inMST[i]) {
|
||||||
|
pq.push({edge.v, i, DistanceL2(points[edge.v], points[i], GetPointFunc)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mstEdges;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<size_t> FindOddDegreeVertices(const std::vector<Edge>& mstEdges, size_t n) {
|
||||||
|
std::vector<size_t> degree(n, 0);
|
||||||
|
for (const auto& edge : mstEdges) {
|
||||||
|
degree[edge.u]++;
|
||||||
|
degree[edge.v]++;
|
||||||
|
}
|
||||||
|
std::vector<size_t> oddVertices;
|
||||||
|
for (size_t i = 0; i < n; ++i) {
|
||||||
|
if (degree[i] % 2 == 1) {
|
||||||
|
oddVertices.push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return oddVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <PointConvertible T>
|
||||||
|
std::vector<Edge> MinPerfectMatching(const std::vector<T>& points, const std::vector<size_t>& oddVertices, std::function<Point(const T&)> GetPointFunc) {
|
||||||
|
size_t m = oddVertices.size();
|
||||||
|
std::vector<Edge> matching;
|
||||||
|
std::unordered_set<size_t> matched;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m; ++i) {
|
||||||
|
if (matched.count(oddVertices[i])) continue;
|
||||||
|
double minDist = std::numeric_limits<double>::max();
|
||||||
|
size_t bestMatch = -1;
|
||||||
|
for (size_t j = i + 1; j < m; ++j) {
|
||||||
|
if (matched.count(oddVertices[j])) continue;
|
||||||
|
double dist = DistanceL2(points[oddVertices[i]], points[oddVertices[j]], GetPointFunc);
|
||||||
|
if (dist < minDist) {
|
||||||
|
minDist = dist;
|
||||||
|
bestMatch = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bestMatch != static_cast<size_t>(-1)) {
|
||||||
|
matching.push_back({oddVertices[i], oddVertices[bestMatch], minDist});
|
||||||
|
matched.insert(oddVertices[i]);
|
||||||
|
matched.insert(oddVertices[bestMatch]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matching;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<size_t> EulerianTour(const Graph& graph, size_t n) {
|
||||||
|
std::vector<size_t> tour;
|
||||||
|
std::vector<size_t> stack;
|
||||||
|
std::vector<std::vector<bool>> visited(n, std::vector<bool>(n, false));
|
||||||
|
std::vector<size_t> currEdge(n, 0);
|
||||||
|
|
||||||
|
stack.push_back(0);
|
||||||
|
while (!stack.empty()) {
|
||||||
|
size_t u = stack.back();
|
||||||
|
while (currEdge[u] < graph[u].size() && visited[u][graph[u][currEdge[u]].first]) {
|
||||||
|
++currEdge[u];
|
||||||
|
}
|
||||||
|
if (currEdge[u] == graph[u].size()) {
|
||||||
|
tour.push_back(u);
|
||||||
|
stack.pop_back();
|
||||||
|
} else {
|
||||||
|
size_t v = graph[u][currEdge[u]].first;
|
||||||
|
visited[u][v] = visited[v][u] = true;
|
||||||
|
stack.push_back(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::reverse(tour.begin(), tour.end());
|
||||||
|
return tour;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<size_t> ConvertEulerianToHamiltonian(const std::vector<size_t>& eulerianTour) {
|
||||||
|
std::unordered_set<size_t> visited;
|
||||||
|
std::vector<size_t> hamiltonianPath;
|
||||||
|
for (size_t vertex : eulerianTour) {
|
||||||
|
if (visited.insert(vertex).second) {
|
||||||
|
hamiltonianPath.push_back(vertex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hamiltonianPath.push_back(hamiltonianPath[0]); // Complete the cycle
|
||||||
|
return hamiltonianPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <PointConvertible T>
|
||||||
|
std::vector<size_t> ChristofidesTSP(const std::vector<T>& points, std::function<Point(const T&)> GetPointFunc) {
|
||||||
|
size_t n = points.size();
|
||||||
|
|
||||||
|
// Step 1: Construct MST
|
||||||
|
std::vector<Edge> mstEdges = PrimMST(points, GetPointFunc);
|
||||||
|
|
||||||
|
// Step 2: Find odd degree vertices
|
||||||
|
std::vector<size_t> oddVertices = FindOddDegreeVertices(mstEdges, n);
|
||||||
|
|
||||||
|
// Step 3: Find minimum weight perfect matching
|
||||||
|
std::vector<Edge> matchingEdges = MinPerfectMatching(points, oddVertices, GetPointFunc);
|
||||||
|
|
||||||
|
// Step 4: Combine MST and matching edges to form a multi-graph
|
||||||
|
Graph multiGraph(n);
|
||||||
|
for (const auto& edge : mstEdges) {
|
||||||
|
AddEdge(multiGraph, edge.u, edge.v, edge.weight);
|
||||||
|
}
|
||||||
|
for (const auto& edge : matchingEdges) {
|
||||||
|
AddEdge(multiGraph, edge.u, edge.v, edge.weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 5: Find an Eulerian tour in the multi-graph
|
||||||
|
std::vector<size_t> eulerianTourPath = EulerianTour(multiGraph, n);
|
||||||
|
|
||||||
|
// Step 6: Convert Eulerian tour to Hamiltonian path
|
||||||
|
std::vector<size_t> hamiltonianPath = ConvertEulerianToHamiltonian(eulerianTourPath);
|
||||||
|
|
||||||
|
return hamiltonianPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace TSPSolver
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CHRISTOFIDES_TSP_H
|
||||||
|
|
||||||
|
|
19
lib/DVP2/DVP2.props
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(PlatformToolset)|$(Platform)'=='v143|x64'">
|
||||||
|
<IncludePath>$(SolutionDir)lib\DVP2\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>$(SolutionDir)lib\DVP2\lib\x64;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(PlatformToolset)|$(Platform)'=='v143|x86'">
|
||||||
|
<IncludePath>$(SolutionDir)lib\DVP2\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>$(SolutionDir)lib\DVP2\lib\x86;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(PlatformToolset)'=='v143'">
|
||||||
|
<Link Condition="'$(Platform)'=='x64'">
|
||||||
|
<AdditionalDependencies>DVPCamera64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<Link Condition="'$(Platform)'=='x86'">
|
||||||
|
<AdditionalDependencies>DVPCamera.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
</Project>
|
BIN
lib/DVP2/bin/x86/DVPCamera.dll
Normal file
6031
lib/DVP2/include/DVPCamera.h
Normal file
BIN
lib/DVP2/lib/x86/DVPCamera.lib
(Stored with Git LFS)
Normal file
15
lib/OpenSSL/OpenSSL.props
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(PlatformToolset)'=='v143'">
|
||||||
|
<IncludePath>$(SolutionDir)lib\OpenSSL\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>$(SolutionDir)lib\OpenSSL\lib;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(PlatformToolset)'=='v143'">
|
||||||
|
<Link Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<AdditionalDependencies>libcrypto64MDd.lib;libcrypto64MTd.lib;libssl64MDd.lib;libssl64MTd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<Link Condition="'$(Configuration)'=='Release'">
|
||||||
|
<AdditionalDependencies>libcrypto64MD.lib;libcrypto64MT.lib;libssl64MD.lib;libssl64MT.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
</Project>
|
BIN
lib/OpenSSL/bin/libcrypto-1_1-x64.dll
Normal file
BIN
lib/OpenSSL/bin/libssl-1_1-x64.dll
Normal file
22
lib/OpenSSL/include/openssl/__DECC_INCLUDE_EPILOGUE.H
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is only used by HP C/C++ on VMS, and is included automatically
|
||||||
|
* after each header file from this directory
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The C++ compiler doesn't understand these pragmas, even though it
|
||||||
|
* understands the corresponding command line qualifier.
|
||||||
|
*/
|
||||||
|
#ifndef __cplusplus
|
||||||
|
/* restore state. Must correspond to the save in __decc_include_prologue.h */
|
||||||
|
# pragma names restore
|
||||||
|
#endif
|
26
lib/OpenSSL/include/openssl/__DECC_INCLUDE_PROLOGUE.H
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is only used by HP C/C++ on VMS, and is included automatically
|
||||||
|
* after each header file from this directory
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The C++ compiler doesn't understand these pragmas, even though it
|
||||||
|
* understands the corresponding command line qualifier.
|
||||||
|
*/
|
||||||
|
#ifndef __cplusplus
|
||||||
|
/* save state */
|
||||||
|
# pragma names save
|
||||||
|
/* have the compiler shorten symbols larger than 31 chars to 23 chars
|
||||||
|
* followed by a 8 hex char CRC
|
||||||
|
*/
|
||||||
|
# pragma names as_is,shortened
|
||||||
|
#endif
|
92
lib/OpenSSL/include/openssl/aes.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_AES_H
|
||||||
|
# define HEADER_AES_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# include <stddef.h>
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define AES_ENCRYPT 1
|
||||||
|
# define AES_DECRYPT 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Because array size can't be a const in C, the following two are macros.
|
||||||
|
* Both sizes are in bytes.
|
||||||
|
*/
|
||||||
|
# define AES_MAXNR 14
|
||||||
|
# define AES_BLOCK_SIZE 16
|
||||||
|
|
||||||
|
/* This should be a hidden type, but EVP requires that the size be known */
|
||||||
|
struct aes_key_st {
|
||||||
|
# ifdef AES_LONG
|
||||||
|
unsigned long rd_key[4 * (AES_MAXNR + 1)];
|
||||||
|
# else
|
||||||
|
unsigned int rd_key[4 * (AES_MAXNR + 1)];
|
||||||
|
# endif
|
||||||
|
int rounds;
|
||||||
|
};
|
||||||
|
typedef struct aes_key_st AES_KEY;
|
||||||
|
|
||||||
|
const char *AES_options(void);
|
||||||
|
|
||||||
|
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||||
|
AES_KEY *key);
|
||||||
|
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||||
|
AES_KEY *key);
|
||||||
|
|
||||||
|
void AES_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const AES_KEY *key);
|
||||||
|
void AES_decrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const AES_KEY *key);
|
||||||
|
|
||||||
|
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const AES_KEY *key, const int enc);
|
||||||
|
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const AES_KEY *key,
|
||||||
|
unsigned char *ivec, const int enc);
|
||||||
|
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const AES_KEY *key,
|
||||||
|
unsigned char *ivec, int *num, const int enc);
|
||||||
|
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const AES_KEY *key,
|
||||||
|
unsigned char *ivec, int *num, const int enc);
|
||||||
|
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const AES_KEY *key,
|
||||||
|
unsigned char *ivec, int *num, const int enc);
|
||||||
|
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const AES_KEY *key,
|
||||||
|
unsigned char *ivec, int *num);
|
||||||
|
/* NB: the IV is _two_ blocks long */
|
||||||
|
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const AES_KEY *key,
|
||||||
|
unsigned char *ivec, const int enc);
|
||||||
|
/* NB: the IV is _four_ blocks long */
|
||||||
|
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const AES_KEY *key,
|
||||||
|
const AES_KEY *key2, const unsigned char *ivec,
|
||||||
|
const int enc);
|
||||||
|
|
||||||
|
int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
|
||||||
|
unsigned char *out,
|
||||||
|
const unsigned char *in, unsigned int inlen);
|
||||||
|
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
|
||||||
|
unsigned char *out,
|
||||||
|
const unsigned char *in, unsigned int inlen);
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
138
lib/OpenSSL/include/openssl/applink.c
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define APPLINK_STDIN 1
|
||||||
|
#define APPLINK_STDOUT 2
|
||||||
|
#define APPLINK_STDERR 3
|
||||||
|
#define APPLINK_FPRINTF 4
|
||||||
|
#define APPLINK_FGETS 5
|
||||||
|
#define APPLINK_FREAD 6
|
||||||
|
#define APPLINK_FWRITE 7
|
||||||
|
#define APPLINK_FSETMOD 8
|
||||||
|
#define APPLINK_FEOF 9
|
||||||
|
#define APPLINK_FCLOSE 10 /* should not be used */
|
||||||
|
|
||||||
|
#define APPLINK_FOPEN 11 /* solely for completeness */
|
||||||
|
#define APPLINK_FSEEK 12
|
||||||
|
#define APPLINK_FTELL 13
|
||||||
|
#define APPLINK_FFLUSH 14
|
||||||
|
#define APPLINK_FERROR 15
|
||||||
|
#define APPLINK_CLEARERR 16
|
||||||
|
#define APPLINK_FILENO 17 /* to be used with below */
|
||||||
|
|
||||||
|
#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
|
||||||
|
#define APPLINK_READ 19
|
||||||
|
#define APPLINK_WRITE 20
|
||||||
|
#define APPLINK_LSEEK 21
|
||||||
|
#define APPLINK_CLOSE 22
|
||||||
|
#define APPLINK_MAX 22 /* always same as last macro */
|
||||||
|
|
||||||
|
#ifndef APPMACROS_ONLY
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <io.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
|
||||||
|
static void *app_stdin(void)
|
||||||
|
{
|
||||||
|
return stdin;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *app_stdout(void)
|
||||||
|
{
|
||||||
|
return stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *app_stderr(void)
|
||||||
|
{
|
||||||
|
return stderr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_feof(FILE *fp)
|
||||||
|
{
|
||||||
|
return feof(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_ferror(FILE *fp)
|
||||||
|
{
|
||||||
|
return ferror(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void app_clearerr(FILE *fp)
|
||||||
|
{
|
||||||
|
clearerr(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_fileno(FILE *fp)
|
||||||
|
{
|
||||||
|
return _fileno(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_fsetmod(FILE *fp, char mod)
|
||||||
|
{
|
||||||
|
return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__declspec(dllexport)
|
||||||
|
void **
|
||||||
|
# if defined(__BORLANDC__)
|
||||||
|
/*
|
||||||
|
* __stdcall appears to be the only way to get the name
|
||||||
|
* decoration right with Borland C. Otherwise it works
|
||||||
|
* purely incidentally, as we pass no parameters.
|
||||||
|
*/
|
||||||
|
__stdcall
|
||||||
|
# else
|
||||||
|
__cdecl
|
||||||
|
# endif
|
||||||
|
OPENSSL_Applink(void)
|
||||||
|
{
|
||||||
|
static int once = 1;
|
||||||
|
static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =
|
||||||
|
{ (void *)APPLINK_MAX };
|
||||||
|
|
||||||
|
if (once) {
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
|
||||||
|
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
|
||||||
|
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_READ] = _read;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
|
||||||
|
|
||||||
|
once = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OPENSSL_ApplinkTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
886
lib/OpenSSL/include/openssl/asn1.h
Normal file
@ -0,0 +1,886 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_ASN1_H
|
||||||
|
# define HEADER_ASN1_H
|
||||||
|
|
||||||
|
# include <time.h>
|
||||||
|
# include <openssl/e_os2.h>
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
# include <openssl/bio.h>
|
||||||
|
# include <openssl/safestack.h>
|
||||||
|
# include <openssl/asn1err.h>
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
|
||||||
|
# include <openssl/ossl_typ.h>
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# include <openssl/bn.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||||
|
# undef OPENSSL_EXTERN
|
||||||
|
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# define V_ASN1_UNIVERSAL 0x00
|
||||||
|
# define V_ASN1_APPLICATION 0x40
|
||||||
|
# define V_ASN1_CONTEXT_SPECIFIC 0x80
|
||||||
|
# define V_ASN1_PRIVATE 0xc0
|
||||||
|
|
||||||
|
# define V_ASN1_CONSTRUCTED 0x20
|
||||||
|
# define V_ASN1_PRIMITIVE_TAG 0x1f
|
||||||
|
# define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG
|
||||||
|
|
||||||
|
# define V_ASN1_APP_CHOOSE -2/* let the recipient choose */
|
||||||
|
# define V_ASN1_OTHER -3/* used in ASN1_TYPE */
|
||||||
|
# define V_ASN1_ANY -4/* used in ASN1 template code */
|
||||||
|
|
||||||
|
# define V_ASN1_UNDEF -1
|
||||||
|
/* ASN.1 tag values */
|
||||||
|
# define V_ASN1_EOC 0
|
||||||
|
# define V_ASN1_BOOLEAN 1 /**/
|
||||||
|
# define V_ASN1_INTEGER 2
|
||||||
|
# define V_ASN1_BIT_STRING 3
|
||||||
|
# define V_ASN1_OCTET_STRING 4
|
||||||
|
# define V_ASN1_NULL 5
|
||||||
|
# define V_ASN1_OBJECT 6
|
||||||
|
# define V_ASN1_OBJECT_DESCRIPTOR 7
|
||||||
|
# define V_ASN1_EXTERNAL 8
|
||||||
|
# define V_ASN1_REAL 9
|
||||||
|
# define V_ASN1_ENUMERATED 10
|
||||||
|
# define V_ASN1_UTF8STRING 12
|
||||||
|
# define V_ASN1_SEQUENCE 16
|
||||||
|
# define V_ASN1_SET 17
|
||||||
|
# define V_ASN1_NUMERICSTRING 18 /**/
|
||||||
|
# define V_ASN1_PRINTABLESTRING 19
|
||||||
|
# define V_ASN1_T61STRING 20
|
||||||
|
# define V_ASN1_TELETEXSTRING 20/* alias */
|
||||||
|
# define V_ASN1_VIDEOTEXSTRING 21 /**/
|
||||||
|
# define V_ASN1_IA5STRING 22
|
||||||
|
# define V_ASN1_UTCTIME 23
|
||||||
|
# define V_ASN1_GENERALIZEDTIME 24 /**/
|
||||||
|
# define V_ASN1_GRAPHICSTRING 25 /**/
|
||||||
|
# define V_ASN1_ISO64STRING 26 /**/
|
||||||
|
# define V_ASN1_VISIBLESTRING 26/* alias */
|
||||||
|
# define V_ASN1_GENERALSTRING 27 /**/
|
||||||
|
# define V_ASN1_UNIVERSALSTRING 28 /**/
|
||||||
|
# define V_ASN1_BMPSTRING 30
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NB the constants below are used internally by ASN1_INTEGER
|
||||||
|
* and ASN1_ENUMERATED to indicate the sign. They are *not* on
|
||||||
|
* the wire tag values.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define V_ASN1_NEG 0x100
|
||||||
|
# define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
|
||||||
|
# define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
|
||||||
|
|
||||||
|
/* For use with d2i_ASN1_type_bytes() */
|
||||||
|
# define B_ASN1_NUMERICSTRING 0x0001
|
||||||
|
# define B_ASN1_PRINTABLESTRING 0x0002
|
||||||
|
# define B_ASN1_T61STRING 0x0004
|
||||||
|
# define B_ASN1_TELETEXSTRING 0x0004
|
||||||
|
# define B_ASN1_VIDEOTEXSTRING 0x0008
|
||||||
|
# define B_ASN1_IA5STRING 0x0010
|
||||||
|
# define B_ASN1_GRAPHICSTRING 0x0020
|
||||||
|
# define B_ASN1_ISO64STRING 0x0040
|
||||||
|
# define B_ASN1_VISIBLESTRING 0x0040
|
||||||
|
# define B_ASN1_GENERALSTRING 0x0080
|
||||||
|
# define B_ASN1_UNIVERSALSTRING 0x0100
|
||||||
|
# define B_ASN1_OCTET_STRING 0x0200
|
||||||
|
# define B_ASN1_BIT_STRING 0x0400
|
||||||
|
# define B_ASN1_BMPSTRING 0x0800
|
||||||
|
# define B_ASN1_UNKNOWN 0x1000
|
||||||
|
# define B_ASN1_UTF8STRING 0x2000
|
||||||
|
# define B_ASN1_UTCTIME 0x4000
|
||||||
|
# define B_ASN1_GENERALIZEDTIME 0x8000
|
||||||
|
# define B_ASN1_SEQUENCE 0x10000
|
||||||
|
/* For use with ASN1_mbstring_copy() */
|
||||||
|
# define MBSTRING_FLAG 0x1000
|
||||||
|
# define MBSTRING_UTF8 (MBSTRING_FLAG)
|
||||||
|
# define MBSTRING_ASC (MBSTRING_FLAG|1)
|
||||||
|
# define MBSTRING_BMP (MBSTRING_FLAG|2)
|
||||||
|
# define MBSTRING_UNIV (MBSTRING_FLAG|4)
|
||||||
|
# define SMIME_OLDMIME 0x400
|
||||||
|
# define SMIME_CRLFEOL 0x800
|
||||||
|
# define SMIME_STREAM 0x1000
|
||||||
|
struct X509_algor_st;
|
||||||
|
DEFINE_STACK_OF(X509_ALGOR)
|
||||||
|
|
||||||
|
# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */
|
||||||
|
/*
|
||||||
|
* This indicates that the ASN1_STRING is not a real value but just a place
|
||||||
|
* holder for the location where indefinite length constructed data should be
|
||||||
|
* inserted in the memory buffer
|
||||||
|
*/
|
||||||
|
# define ASN1_STRING_FLAG_NDEF 0x010
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This flag is used by the CMS code to indicate that a string is not
|
||||||
|
* complete and is a place holder for content when it had all been accessed.
|
||||||
|
* The flag will be reset when content has been written to it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRING_FLAG_CONT 0x020
|
||||||
|
/*
|
||||||
|
* This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING
|
||||||
|
* type.
|
||||||
|
*/
|
||||||
|
# define ASN1_STRING_FLAG_MSTRING 0x040
|
||||||
|
/* String is embedded and only content should be freed */
|
||||||
|
# define ASN1_STRING_FLAG_EMBED 0x080
|
||||||
|
/* String should be parsed in RFC 5280's time format */
|
||||||
|
# define ASN1_STRING_FLAG_X509_TIME 0x100
|
||||||
|
/* This is the base type that holds just about everything :-) */
|
||||||
|
struct asn1_string_st {
|
||||||
|
int length;
|
||||||
|
int type;
|
||||||
|
unsigned char *data;
|
||||||
|
/*
|
||||||
|
* The value of the following field depends on the type being held. It
|
||||||
|
* is mostly being used for BIT_STRING so if the input data has a
|
||||||
|
* non-zero 'unused bits' value, it will be handled correctly
|
||||||
|
*/
|
||||||
|
long flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASN1_ENCODING structure: this is used to save the received encoding of an
|
||||||
|
* ASN1 type. This is useful to get round problems with invalid encodings
|
||||||
|
* which can break signatures.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct ASN1_ENCODING_st {
|
||||||
|
unsigned char *enc; /* DER encoding */
|
||||||
|
long len; /* Length of encoding */
|
||||||
|
int modified; /* set to 1 if 'enc' is invalid */
|
||||||
|
} ASN1_ENCODING;
|
||||||
|
|
||||||
|
/* Used with ASN1 LONG type: if a long is set to this it is omitted */
|
||||||
|
# define ASN1_LONG_UNDEF 0x7fffffffL
|
||||||
|
|
||||||
|
# define STABLE_FLAGS_MALLOC 0x01
|
||||||
|
/*
|
||||||
|
* A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted
|
||||||
|
* as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting
|
||||||
|
* STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias
|
||||||
|
* STABLE_FLAGS_CLEAR to reflect this.
|
||||||
|
*/
|
||||||
|
# define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC
|
||||||
|
# define STABLE_NO_MASK 0x02
|
||||||
|
# define DIRSTRING_TYPE \
|
||||||
|
(B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
|
||||||
|
# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
|
||||||
|
|
||||||
|
typedef struct asn1_string_table_st {
|
||||||
|
int nid;
|
||||||
|
long minsize;
|
||||||
|
long maxsize;
|
||||||
|
unsigned long mask;
|
||||||
|
unsigned long flags;
|
||||||
|
} ASN1_STRING_TABLE;
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_STRING_TABLE)
|
||||||
|
|
||||||
|
/* size limits: this stuff is taken straight from RFC2459 */
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Declarations for template structures: for full definitions see asn1t.h
|
||||||
|
*/
|
||||||
|
typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
|
||||||
|
typedef struct ASN1_TLC_st ASN1_TLC;
|
||||||
|
/* This is just an opaque pointer */
|
||||||
|
typedef struct ASN1_VALUE_st ASN1_VALUE;
|
||||||
|
|
||||||
|
/* Declare ASN1 functions: the implement macro in in asn1t.h */
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
|
||||||
|
DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_FUNCTIONS_name(type, name) \
|
||||||
|
DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
|
||||||
|
DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
|
||||||
|
DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
|
||||||
|
DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
|
||||||
|
type *d2i_##name(type **a, const unsigned char **in, long len); \
|
||||||
|
int i2d_##name(type *a, unsigned char **out); \
|
||||||
|
DECLARE_ASN1_ITEM(itname)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
|
||||||
|
type *d2i_##name(type **a, const unsigned char **in, long len); \
|
||||||
|
int i2d_##name(const type *a, unsigned char **out); \
|
||||||
|
DECLARE_ASN1_ITEM(name)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_NDEF_FUNCTION(name) \
|
||||||
|
int i2d_##name##_NDEF(name *a, unsigned char **out);
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_FUNCTIONS_const(name) \
|
||||||
|
DECLARE_ASN1_ALLOC_FUNCTIONS(name) \
|
||||||
|
DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
|
||||||
|
type *name##_new(void); \
|
||||||
|
void name##_free(type *a);
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_PRINT_FUNCTION(stname) \
|
||||||
|
DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \
|
||||||
|
int fname##_print_ctx(BIO *out, stname *x, int indent, \
|
||||||
|
const ASN1_PCTX *pctx);
|
||||||
|
|
||||||
|
# define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
|
||||||
|
# define I2D_OF(type) int (*)(type *,unsigned char **)
|
||||||
|
# define I2D_OF_const(type) int (*)(const type *,unsigned char **)
|
||||||
|
|
||||||
|
# define CHECKED_D2I_OF(type, d2i) \
|
||||||
|
((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))
|
||||||
|
# define CHECKED_I2D_OF(type, i2d) \
|
||||||
|
((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))
|
||||||
|
# define CHECKED_NEW_OF(type, xnew) \
|
||||||
|
((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))
|
||||||
|
# define CHECKED_PTR_OF(type, p) \
|
||||||
|
((void*) (1 ? p : (type*)0))
|
||||||
|
# define CHECKED_PPTR_OF(type, p) \
|
||||||
|
((void**) (1 ? p : (type**)0))
|
||||||
|
|
||||||
|
# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
|
||||||
|
# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)
|
||||||
|
# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
|
||||||
|
|
||||||
|
TYPEDEF_D2I2D_OF(void);
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* The following macros and typedefs allow an ASN1_ITEM
|
||||||
|
* to be embedded in a structure and referenced. Since
|
||||||
|
* the ASN1_ITEM pointers need to be globally accessible
|
||||||
|
* (possibly from shared libraries) they may exist in
|
||||||
|
* different forms. On platforms that support it the
|
||||||
|
* ASN1_ITEM structure itself will be globally exported.
|
||||||
|
* Other platforms will export a function that returns
|
||||||
|
* an ASN1_ITEM pointer.
|
||||||
|
*
|
||||||
|
* To handle both cases transparently the macros below
|
||||||
|
* should be used instead of hard coding an ASN1_ITEM
|
||||||
|
* pointer in a structure.
|
||||||
|
*
|
||||||
|
* The structure will look like this:
|
||||||
|
*
|
||||||
|
* typedef struct SOMETHING_st {
|
||||||
|
* ...
|
||||||
|
* ASN1_ITEM_EXP *iptr;
|
||||||
|
* ...
|
||||||
|
* } SOMETHING;
|
||||||
|
*
|
||||||
|
* It would be initialised as e.g.:
|
||||||
|
*
|
||||||
|
* SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
|
||||||
|
*
|
||||||
|
* and the actual pointer extracted with:
|
||||||
|
*
|
||||||
|
* const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
|
||||||
|
*
|
||||||
|
* Finally an ASN1_ITEM pointer can be extracted from an
|
||||||
|
* appropriate reference with: ASN1_ITEM_rptr(X509). This
|
||||||
|
* would be used when a function takes an ASN1_ITEM * argument.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||||
|
|
||||||
|
/* ASN1_ITEM pointer exported type */
|
||||||
|
typedef const ASN1_ITEM ASN1_ITEM_EXP;
|
||||||
|
|
||||||
|
/* Macro to obtain ASN1_ITEM pointer from exported type */
|
||||||
|
# define ASN1_ITEM_ptr(iptr) (iptr)
|
||||||
|
|
||||||
|
/* Macro to include ASN1_ITEM pointer from base type */
|
||||||
|
# define ASN1_ITEM_ref(iptr) (&(iptr##_it))
|
||||||
|
|
||||||
|
# define ASN1_ITEM_rptr(ref) (&(ref##_it))
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_ITEM(name) \
|
||||||
|
OPENSSL_EXTERN const ASN1_ITEM name##_it;
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platforms that can't easily handle shared global variables are declared as
|
||||||
|
* functions returning ASN1_ITEM pointers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ASN1_ITEM pointer exported type */
|
||||||
|
typedef const ASN1_ITEM *ASN1_ITEM_EXP (void);
|
||||||
|
|
||||||
|
/* Macro to obtain ASN1_ITEM pointer from exported type */
|
||||||
|
# define ASN1_ITEM_ptr(iptr) (iptr())
|
||||||
|
|
||||||
|
/* Macro to include ASN1_ITEM pointer from base type */
|
||||||
|
# define ASN1_ITEM_ref(iptr) (iptr##_it)
|
||||||
|
|
||||||
|
# define ASN1_ITEM_rptr(ref) (ref##_it())
|
||||||
|
|
||||||
|
# define DECLARE_ASN1_ITEM(name) \
|
||||||
|
const ASN1_ITEM * name##_it(void);
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Parameters used by ASN1_STRING_print_ex() */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These determine which characters to escape: RFC2253 special characters,
|
||||||
|
* control characters and MSB set characters
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRFLGS_ESC_2253 1
|
||||||
|
# define ASN1_STRFLGS_ESC_CTRL 2
|
||||||
|
# define ASN1_STRFLGS_ESC_MSB 4
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This flag determines how we do escaping: normally RC2253 backslash only,
|
||||||
|
* set this to use backslash and quote.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRFLGS_ESC_QUOTE 8
|
||||||
|
|
||||||
|
/* These three flags are internal use only. */
|
||||||
|
|
||||||
|
/* Character is a valid PrintableString character */
|
||||||
|
# define CHARTYPE_PRINTABLESTRING 0x10
|
||||||
|
/* Character needs escaping if it is the first character */
|
||||||
|
# define CHARTYPE_FIRST_ESC_2253 0x20
|
||||||
|
/* Character needs escaping if it is the last character */
|
||||||
|
# define CHARTYPE_LAST_ESC_2253 0x40
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NB the internal flags are safely reused below by flags handled at the top
|
||||||
|
* level.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this is set we convert all character strings to UTF8 first
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRFLGS_UTF8_CONVERT 0x10
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this is set we don't attempt to interpret content: just assume all
|
||||||
|
* strings are 1 byte per character. This will produce some pretty odd
|
||||||
|
* looking output!
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRFLGS_IGNORE_TYPE 0x20
|
||||||
|
|
||||||
|
/* If this is set we include the string type in the output */
|
||||||
|
# define ASN1_STRFLGS_SHOW_TYPE 0x40
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This determines which strings to display and which to 'dump' (hex dump of
|
||||||
|
* content octets or DER encoding). We can only dump non character strings or
|
||||||
|
* everything. If we don't dump 'unknown' they are interpreted as character
|
||||||
|
* strings with 1 octet per character and are subject to the usual escaping
|
||||||
|
* options.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRFLGS_DUMP_ALL 0x80
|
||||||
|
# define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These determine what 'dumping' does, we can dump the content octets or the
|
||||||
|
* DER encoding: both use the RFC2253 #XXXXX notation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRFLGS_DUMP_DER 0x200
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This flag specifies that RC2254 escaping shall be performed.
|
||||||
|
*/
|
||||||
|
#define ASN1_STRFLGS_ESC_2254 0x400
|
||||||
|
|
||||||
|
/*
|
||||||
|
* All the string flags consistent with RFC2253, escaping control characters
|
||||||
|
* isn't essential in RFC2253 but it is advisable anyway.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
|
||||||
|
ASN1_STRFLGS_ESC_CTRL | \
|
||||||
|
ASN1_STRFLGS_ESC_MSB | \
|
||||||
|
ASN1_STRFLGS_UTF8_CONVERT | \
|
||||||
|
ASN1_STRFLGS_DUMP_UNKNOWN | \
|
||||||
|
ASN1_STRFLGS_DUMP_DER)
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_INTEGER)
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_GENERALSTRING)
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_UTF8STRING)
|
||||||
|
|
||||||
|
typedef struct asn1_type_st {
|
||||||
|
int type;
|
||||||
|
union {
|
||||||
|
char *ptr;
|
||||||
|
ASN1_BOOLEAN boolean;
|
||||||
|
ASN1_STRING *asn1_string;
|
||||||
|
ASN1_OBJECT *object;
|
||||||
|
ASN1_INTEGER *integer;
|
||||||
|
ASN1_ENUMERATED *enumerated;
|
||||||
|
ASN1_BIT_STRING *bit_string;
|
||||||
|
ASN1_OCTET_STRING *octet_string;
|
||||||
|
ASN1_PRINTABLESTRING *printablestring;
|
||||||
|
ASN1_T61STRING *t61string;
|
||||||
|
ASN1_IA5STRING *ia5string;
|
||||||
|
ASN1_GENERALSTRING *generalstring;
|
||||||
|
ASN1_BMPSTRING *bmpstring;
|
||||||
|
ASN1_UNIVERSALSTRING *universalstring;
|
||||||
|
ASN1_UTCTIME *utctime;
|
||||||
|
ASN1_GENERALIZEDTIME *generalizedtime;
|
||||||
|
ASN1_VISIBLESTRING *visiblestring;
|
||||||
|
ASN1_UTF8STRING *utf8string;
|
||||||
|
/*
|
||||||
|
* set and sequence are left complete and still contain the set or
|
||||||
|
* sequence bytes
|
||||||
|
*/
|
||||||
|
ASN1_STRING *set;
|
||||||
|
ASN1_STRING *sequence;
|
||||||
|
ASN1_VALUE *asn1_value;
|
||||||
|
} value;
|
||||||
|
} ASN1_TYPE;
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_TYPE)
|
||||||
|
|
||||||
|
typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;
|
||||||
|
|
||||||
|
DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
|
||||||
|
DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)
|
||||||
|
|
||||||
|
/* This is used to contain a list of bit names */
|
||||||
|
typedef struct BIT_STRING_BITNAME_st {
|
||||||
|
int bitnum;
|
||||||
|
const char *lname;
|
||||||
|
const char *sname;
|
||||||
|
} BIT_STRING_BITNAME;
|
||||||
|
|
||||||
|
# define B_ASN1_TIME \
|
||||||
|
B_ASN1_UTCTIME | \
|
||||||
|
B_ASN1_GENERALIZEDTIME
|
||||||
|
|
||||||
|
# define B_ASN1_PRINTABLE \
|
||||||
|
B_ASN1_NUMERICSTRING| \
|
||||||
|
B_ASN1_PRINTABLESTRING| \
|
||||||
|
B_ASN1_T61STRING| \
|
||||||
|
B_ASN1_IA5STRING| \
|
||||||
|
B_ASN1_BIT_STRING| \
|
||||||
|
B_ASN1_UNIVERSALSTRING|\
|
||||||
|
B_ASN1_BMPSTRING|\
|
||||||
|
B_ASN1_UTF8STRING|\
|
||||||
|
B_ASN1_SEQUENCE|\
|
||||||
|
B_ASN1_UNKNOWN
|
||||||
|
|
||||||
|
# define B_ASN1_DIRECTORYSTRING \
|
||||||
|
B_ASN1_PRINTABLESTRING| \
|
||||||
|
B_ASN1_TELETEXSTRING|\
|
||||||
|
B_ASN1_BMPSTRING|\
|
||||||
|
B_ASN1_UNIVERSALSTRING|\
|
||||||
|
B_ASN1_UTF8STRING
|
||||||
|
|
||||||
|
# define B_ASN1_DISPLAYTEXT \
|
||||||
|
B_ASN1_IA5STRING| \
|
||||||
|
B_ASN1_VISIBLESTRING| \
|
||||||
|
B_ASN1_BMPSTRING|\
|
||||||
|
B_ASN1_UTF8STRING
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
|
||||||
|
|
||||||
|
int ASN1_TYPE_get(const ASN1_TYPE *a);
|
||||||
|
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
|
||||||
|
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
|
||||||
|
int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
|
||||||
|
|
||||||
|
ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t);
|
||||||
|
void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
|
||||||
|
|
||||||
|
ASN1_OBJECT *ASN1_OBJECT_new(void);
|
||||||
|
void ASN1_OBJECT_free(ASN1_OBJECT *a);
|
||||||
|
int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp);
|
||||||
|
ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||||
|
long length);
|
||||||
|
|
||||||
|
DECLARE_ASN1_ITEM(ASN1_OBJECT)
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_OBJECT)
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_STRING_new(void);
|
||||||
|
void ASN1_STRING_free(ASN1_STRING *a);
|
||||||
|
void ASN1_STRING_clear_free(ASN1_STRING *a);
|
||||||
|
int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
|
||||||
|
ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);
|
||||||
|
ASN1_STRING *ASN1_STRING_type_new(int type);
|
||||||
|
int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
|
||||||
|
/*
|
||||||
|
* Since this is used to store all sorts of things, via macros, for now,
|
||||||
|
* make its data void *
|
||||||
|
*/
|
||||||
|
int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
|
||||||
|
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
|
||||||
|
int ASN1_STRING_length(const ASN1_STRING *x);
|
||||||
|
void ASN1_STRING_length_set(ASN1_STRING *x, int n);
|
||||||
|
int ASN1_STRING_type(const ASN1_STRING *x);
|
||||||
|
DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
|
||||||
|
const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
|
||||||
|
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);
|
||||||
|
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
|
||||||
|
int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n);
|
||||||
|
int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,
|
||||||
|
const unsigned char *flags, int flags_len);
|
||||||
|
|
||||||
|
int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
|
||||||
|
BIT_STRING_BITNAME *tbl, int indent);
|
||||||
|
int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);
|
||||||
|
int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,
|
||||||
|
BIT_STRING_BITNAME *tbl);
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
|
||||||
|
ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
|
||||||
|
long length);
|
||||||
|
ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);
|
||||||
|
int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
|
||||||
|
|
||||||
|
int ASN1_UTCTIME_check(const ASN1_UTCTIME *a);
|
||||||
|
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);
|
||||||
|
ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
|
||||||
|
int offset_day, long offset_sec);
|
||||||
|
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
|
||||||
|
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
|
||||||
|
|
||||||
|
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
|
||||||
|
time_t t);
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
|
||||||
|
time_t t, int offset_day,
|
||||||
|
long offset_sec);
|
||||||
|
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
|
||||||
|
|
||||||
|
int ASN1_TIME_diff(int *pday, int *psec,
|
||||||
|
const ASN1_TIME *from, const ASN1_TIME *to);
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
|
||||||
|
ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
|
||||||
|
int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
|
||||||
|
const ASN1_OCTET_STRING *b);
|
||||||
|
int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,
|
||||||
|
int len);
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
|
||||||
|
|
||||||
|
int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
|
||||||
|
int UTF8_putc(unsigned char *str, int len, unsigned long value);
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
|
||||||
|
|
||||||
|
DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
|
||||||
|
|
||||||
|
DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
|
||||||
|
|
||||||
|
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
|
||||||
|
ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
|
||||||
|
int offset_day, long offset_sec);
|
||||||
|
int ASN1_TIME_check(const ASN1_TIME *t);
|
||||||
|
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
|
||||||
|
ASN1_GENERALIZEDTIME **out);
|
||||||
|
int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
|
||||||
|
int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str);
|
||||||
|
int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm);
|
||||||
|
int ASN1_TIME_normalize(ASN1_TIME *s);
|
||||||
|
int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t);
|
||||||
|
int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b);
|
||||||
|
|
||||||
|
int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a);
|
||||||
|
int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);
|
||||||
|
int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a);
|
||||||
|
int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);
|
||||||
|
int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a);
|
||||||
|
int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);
|
||||||
|
int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type);
|
||||||
|
int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a);
|
||||||
|
|
||||||
|
int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);
|
||||||
|
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
|
||||||
|
const char *sn, const char *ln);
|
||||||
|
|
||||||
|
int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);
|
||||||
|
int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);
|
||||||
|
int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);
|
||||||
|
int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);
|
||||||
|
|
||||||
|
int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
|
||||||
|
long ASN1_INTEGER_get(const ASN1_INTEGER *a);
|
||||||
|
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
|
||||||
|
BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);
|
||||||
|
|
||||||
|
int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);
|
||||||
|
int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);
|
||||||
|
|
||||||
|
|
||||||
|
int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
|
||||||
|
long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);
|
||||||
|
ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);
|
||||||
|
BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);
|
||||||
|
|
||||||
|
/* General */
|
||||||
|
/* given a string, return the correct type, max is the maximum length */
|
||||||
|
int ASN1_PRINTABLE_type(const unsigned char *s, int max);
|
||||||
|
|
||||||
|
unsigned long ASN1_tag2bit(int tag);
|
||||||
|
|
||||||
|
/* SPECIALS */
|
||||||
|
int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
|
||||||
|
int *pclass, long omax);
|
||||||
|
int ASN1_check_infinite_end(unsigned char **p, long len);
|
||||||
|
int ASN1_const_check_infinite_end(const unsigned char **p, long len);
|
||||||
|
void ASN1_put_object(unsigned char **pp, int constructed, int length,
|
||||||
|
int tag, int xclass);
|
||||||
|
int ASN1_put_eoc(unsigned char **pp);
|
||||||
|
int ASN1_object_size(int constructed, int length, int tag);
|
||||||
|
|
||||||
|
/* Used to implement other functions */
|
||||||
|
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);
|
||||||
|
|
||||||
|
# define ASN1_dup_of(type,i2d,d2i,x) \
|
||||||
|
((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
|
||||||
|
CHECKED_D2I_OF(type, d2i), \
|
||||||
|
CHECKED_PTR_OF(type, x)))
|
||||||
|
|
||||||
|
# define ASN1_dup_of_const(type,i2d,d2i,x) \
|
||||||
|
((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \
|
||||||
|
CHECKED_D2I_OF(type, d2i), \
|
||||||
|
CHECKED_PTR_OF(const type, x)))
|
||||||
|
|
||||||
|
void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
|
||||||
|
|
||||||
|
/* ASN1 alloc/free macros for when a type is only used internally */
|
||||||
|
|
||||||
|
# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))
|
||||||
|
# define M_ASN1_free_of(x, type) \
|
||||||
|
ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);
|
||||||
|
|
||||||
|
# define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
|
||||||
|
((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \
|
||||||
|
CHECKED_D2I_OF(type, d2i), \
|
||||||
|
in, \
|
||||||
|
CHECKED_PPTR_OF(type, x)))
|
||||||
|
|
||||||
|
void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
|
||||||
|
int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);
|
||||||
|
|
||||||
|
# define ASN1_i2d_fp_of(type,i2d,out,x) \
|
||||||
|
(ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \
|
||||||
|
out, \
|
||||||
|
CHECKED_PTR_OF(type, x)))
|
||||||
|
|
||||||
|
# define ASN1_i2d_fp_of_const(type,i2d,out,x) \
|
||||||
|
(ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \
|
||||||
|
out, \
|
||||||
|
CHECKED_PTR_OF(const type, x)))
|
||||||
|
|
||||||
|
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
|
||||||
|
int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);
|
||||||
|
|
||||||
|
void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);
|
||||||
|
|
||||||
|
# define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
|
||||||
|
((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \
|
||||||
|
CHECKED_D2I_OF(type, d2i), \
|
||||||
|
in, \
|
||||||
|
CHECKED_PPTR_OF(type, x)))
|
||||||
|
|
||||||
|
void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
|
||||||
|
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);
|
||||||
|
|
||||||
|
# define ASN1_i2d_bio_of(type,i2d,out,x) \
|
||||||
|
(ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \
|
||||||
|
out, \
|
||||||
|
CHECKED_PTR_OF(type, x)))
|
||||||
|
|
||||||
|
# define ASN1_i2d_bio_of_const(type,i2d,out,x) \
|
||||||
|
(ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \
|
||||||
|
out, \
|
||||||
|
CHECKED_PTR_OF(const type, x)))
|
||||||
|
|
||||||
|
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
|
||||||
|
int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
|
||||||
|
int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
|
||||||
|
int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);
|
||||||
|
int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
|
||||||
|
int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);
|
||||||
|
int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off);
|
||||||
|
int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
|
||||||
|
unsigned char *buf, int off);
|
||||||
|
int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);
|
||||||
|
int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,
|
||||||
|
int dump);
|
||||||
|
const char *ASN1_tag2str(int tag);
|
||||||
|
|
||||||
|
/* Used to load and write Netscape format cert */
|
||||||
|
|
||||||
|
int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
|
||||||
|
|
||||||
|
int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);
|
||||||
|
int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len);
|
||||||
|
int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
|
||||||
|
unsigned char *data, int len);
|
||||||
|
int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num,
|
||||||
|
unsigned char *data, int max_len);
|
||||||
|
|
||||||
|
void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it);
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,
|
||||||
|
ASN1_OCTET_STRING **oct);
|
||||||
|
|
||||||
|
void ASN1_STRING_set_default_mask(unsigned long mask);
|
||||||
|
int ASN1_STRING_set_default_mask_asc(const char *p);
|
||||||
|
unsigned long ASN1_STRING_get_default_mask(void);
|
||||||
|
int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||||
|
int inform, unsigned long mask);
|
||||||
|
int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||||
|
int inform, unsigned long mask,
|
||||||
|
long minsize, long maxsize);
|
||||||
|
|
||||||
|
ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
|
||||||
|
const unsigned char *in, int inlen,
|
||||||
|
int inform, int nid);
|
||||||
|
ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
|
||||||
|
int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
|
||||||
|
void ASN1_STRING_TABLE_cleanup(void);
|
||||||
|
|
||||||
|
/* ASN1 template functions */
|
||||||
|
|
||||||
|
/* Old API compatible functions */
|
||||||
|
ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
|
||||||
|
void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
|
||||||
|
ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,
|
||||||
|
long len, const ASN1_ITEM *it);
|
||||||
|
int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
|
||||||
|
int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||||
|
const ASN1_ITEM *it);
|
||||||
|
|
||||||
|
void ASN1_add_oid_module(void);
|
||||||
|
void ASN1_add_stable_module(void);
|
||||||
|
|
||||||
|
ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf);
|
||||||
|
ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf);
|
||||||
|
int ASN1_str2mask(const char *str, unsigned long *pmask);
|
||||||
|
|
||||||
|
/* ASN1 Print flags */
|
||||||
|
|
||||||
|
/* Indicate missing OPTIONAL fields */
|
||||||
|
# define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001
|
||||||
|
/* Mark start and end of SEQUENCE */
|
||||||
|
# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002
|
||||||
|
/* Mark start and end of SEQUENCE/SET OF */
|
||||||
|
# define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004
|
||||||
|
/* Show the ASN1 type of primitives */
|
||||||
|
# define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008
|
||||||
|
/* Don't show ASN1 type of ANY */
|
||||||
|
# define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010
|
||||||
|
/* Don't show ASN1 type of MSTRINGs */
|
||||||
|
# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020
|
||||||
|
/* Don't show field names in SEQUENCE */
|
||||||
|
# define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040
|
||||||
|
/* Show structure names of each SEQUENCE field */
|
||||||
|
# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080
|
||||||
|
/* Don't show structure name even at top level */
|
||||||
|
# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100
|
||||||
|
|
||||||
|
int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
|
||||||
|
const ASN1_ITEM *it, const ASN1_PCTX *pctx);
|
||||||
|
ASN1_PCTX *ASN1_PCTX_new(void);
|
||||||
|
void ASN1_PCTX_free(ASN1_PCTX *p);
|
||||||
|
unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p);
|
||||||
|
void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
|
||||||
|
unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p);
|
||||||
|
void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
|
||||||
|
unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p);
|
||||||
|
void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
|
||||||
|
unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p);
|
||||||
|
void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
|
||||||
|
unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p);
|
||||||
|
void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);
|
||||||
|
|
||||||
|
ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx));
|
||||||
|
void ASN1_SCTX_free(ASN1_SCTX *p);
|
||||||
|
const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p);
|
||||||
|
const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p);
|
||||||
|
unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p);
|
||||||
|
void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data);
|
||||||
|
void *ASN1_SCTX_get_app_data(ASN1_SCTX *p);
|
||||||
|
|
||||||
|
const BIO_METHOD *BIO_f_asn1(void);
|
||||||
|
|
||||||
|
BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);
|
||||||
|
|
||||||
|
int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
|
||||||
|
const ASN1_ITEM *it);
|
||||||
|
int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
|
||||||
|
const char *hdr, const ASN1_ITEM *it);
|
||||||
|
int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
|
||||||
|
int ctype_nid, int econt_nid,
|
||||||
|
STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);
|
||||||
|
ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
|
||||||
|
int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
|
||||||
|
int SMIME_text(BIO *in, BIO *out);
|
||||||
|
|
||||||
|
const ASN1_ITEM *ASN1_ITEM_lookup(const char *name);
|
||||||
|
const ASN1_ITEM *ASN1_ITEM_get(size_t i);
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
10
lib/OpenSSL/include/openssl/asn1_mac.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#error "This file is obsolete; please update your software."
|
256
lib/OpenSSL/include/openssl/asn1err.h
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_ASN1ERR_H
|
||||||
|
# define HEADER_ASN1ERR_H
|
||||||
|
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_ASN1_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASN1 function codes.
|
||||||
|
*/
|
||||||
|
# define ASN1_F_A2D_ASN1_OBJECT 100
|
||||||
|
# define ASN1_F_A2I_ASN1_INTEGER 102
|
||||||
|
# define ASN1_F_A2I_ASN1_STRING 103
|
||||||
|
# define ASN1_F_APPEND_EXP 176
|
||||||
|
# define ASN1_F_ASN1_BIO_INIT 113
|
||||||
|
# define ASN1_F_ASN1_BIT_STRING_SET_BIT 183
|
||||||
|
# define ASN1_F_ASN1_CB 177
|
||||||
|
# define ASN1_F_ASN1_CHECK_TLEN 104
|
||||||
|
# define ASN1_F_ASN1_COLLECT 106
|
||||||
|
# define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108
|
||||||
|
# define ASN1_F_ASN1_D2I_FP 109
|
||||||
|
# define ASN1_F_ASN1_D2I_READ_BIO 107
|
||||||
|
# define ASN1_F_ASN1_DIGEST 184
|
||||||
|
# define ASN1_F_ASN1_DO_ADB 110
|
||||||
|
# define ASN1_F_ASN1_DO_LOCK 233
|
||||||
|
# define ASN1_F_ASN1_DUP 111
|
||||||
|
# define ASN1_F_ASN1_ENC_SAVE 115
|
||||||
|
# define ASN1_F_ASN1_EX_C2I 204
|
||||||
|
# define ASN1_F_ASN1_FIND_END 190
|
||||||
|
# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 216
|
||||||
|
# define ASN1_F_ASN1_GENERATE_V3 178
|
||||||
|
# define ASN1_F_ASN1_GET_INT64 224
|
||||||
|
# define ASN1_F_ASN1_GET_OBJECT 114
|
||||||
|
# define ASN1_F_ASN1_GET_UINT64 225
|
||||||
|
# define ASN1_F_ASN1_I2D_BIO 116
|
||||||
|
# define ASN1_F_ASN1_I2D_FP 117
|
||||||
|
# define ASN1_F_ASN1_ITEM_D2I_FP 206
|
||||||
|
# define ASN1_F_ASN1_ITEM_DUP 191
|
||||||
|
# define ASN1_F_ASN1_ITEM_EMBED_D2I 120
|
||||||
|
# define ASN1_F_ASN1_ITEM_EMBED_NEW 121
|
||||||
|
# define ASN1_F_ASN1_ITEM_EX_I2D 144
|
||||||
|
# define ASN1_F_ASN1_ITEM_FLAGS_I2D 118
|
||||||
|
# define ASN1_F_ASN1_ITEM_I2D_BIO 192
|
||||||
|
# define ASN1_F_ASN1_ITEM_I2D_FP 193
|
||||||
|
# define ASN1_F_ASN1_ITEM_PACK 198
|
||||||
|
# define ASN1_F_ASN1_ITEM_SIGN 195
|
||||||
|
# define ASN1_F_ASN1_ITEM_SIGN_CTX 220
|
||||||
|
# define ASN1_F_ASN1_ITEM_UNPACK 199
|
||||||
|
# define ASN1_F_ASN1_ITEM_VERIFY 197
|
||||||
|
# define ASN1_F_ASN1_MBSTRING_NCOPY 122
|
||||||
|
# define ASN1_F_ASN1_OBJECT_NEW 123
|
||||||
|
# define ASN1_F_ASN1_OUTPUT_DATA 214
|
||||||
|
# define ASN1_F_ASN1_PCTX_NEW 205
|
||||||
|
# define ASN1_F_ASN1_PRIMITIVE_NEW 119
|
||||||
|
# define ASN1_F_ASN1_SCTX_NEW 221
|
||||||
|
# define ASN1_F_ASN1_SIGN 128
|
||||||
|
# define ASN1_F_ASN1_STR2TYPE 179
|
||||||
|
# define ASN1_F_ASN1_STRING_GET_INT64 227
|
||||||
|
# define ASN1_F_ASN1_STRING_GET_UINT64 230
|
||||||
|
# define ASN1_F_ASN1_STRING_SET 186
|
||||||
|
# define ASN1_F_ASN1_STRING_TABLE_ADD 129
|
||||||
|
# define ASN1_F_ASN1_STRING_TO_BN 228
|
||||||
|
# define ASN1_F_ASN1_STRING_TYPE_NEW 130
|
||||||
|
# define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
|
||||||
|
# define ASN1_F_ASN1_TEMPLATE_NEW 133
|
||||||
|
# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131
|
||||||
|
# define ASN1_F_ASN1_TIME_ADJ 217
|
||||||
|
# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
|
||||||
|
# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
|
||||||
|
# define ASN1_F_ASN1_UTCTIME_ADJ 218
|
||||||
|
# define ASN1_F_ASN1_VERIFY 137
|
||||||
|
# define ASN1_F_B64_READ_ASN1 209
|
||||||
|
# define ASN1_F_B64_WRITE_ASN1 210
|
||||||
|
# define ASN1_F_BIO_NEW_NDEF 208
|
||||||
|
# define ASN1_F_BITSTR_CB 180
|
||||||
|
# define ASN1_F_BN_TO_ASN1_STRING 229
|
||||||
|
# define ASN1_F_C2I_ASN1_BIT_STRING 189
|
||||||
|
# define ASN1_F_C2I_ASN1_INTEGER 194
|
||||||
|
# define ASN1_F_C2I_ASN1_OBJECT 196
|
||||||
|
# define ASN1_F_C2I_IBUF 226
|
||||||
|
# define ASN1_F_C2I_UINT64_INT 101
|
||||||
|
# define ASN1_F_COLLECT_DATA 140
|
||||||
|
# define ASN1_F_D2I_ASN1_OBJECT 147
|
||||||
|
# define ASN1_F_D2I_ASN1_UINTEGER 150
|
||||||
|
# define ASN1_F_D2I_AUTOPRIVATEKEY 207
|
||||||
|
# define ASN1_F_D2I_PRIVATEKEY 154
|
||||||
|
# define ASN1_F_D2I_PUBLICKEY 155
|
||||||
|
# define ASN1_F_DO_BUF 142
|
||||||
|
# define ASN1_F_DO_CREATE 124
|
||||||
|
# define ASN1_F_DO_DUMP 125
|
||||||
|
# define ASN1_F_DO_TCREATE 222
|
||||||
|
# define ASN1_F_I2A_ASN1_OBJECT 126
|
||||||
|
# define ASN1_F_I2D_ASN1_BIO_STREAM 211
|
||||||
|
# define ASN1_F_I2D_ASN1_OBJECT 143
|
||||||
|
# define ASN1_F_I2D_DSA_PUBKEY 161
|
||||||
|
# define ASN1_F_I2D_EC_PUBKEY 181
|
||||||
|
# define ASN1_F_I2D_PRIVATEKEY 163
|
||||||
|
# define ASN1_F_I2D_PUBLICKEY 164
|
||||||
|
# define ASN1_F_I2D_RSA_PUBKEY 165
|
||||||
|
# define ASN1_F_LONG_C2I 166
|
||||||
|
# define ASN1_F_NDEF_PREFIX 127
|
||||||
|
# define ASN1_F_NDEF_SUFFIX 136
|
||||||
|
# define ASN1_F_OID_MODULE_INIT 174
|
||||||
|
# define ASN1_F_PARSE_TAGGING 182
|
||||||
|
# define ASN1_F_PKCS5_PBE2_SET_IV 167
|
||||||
|
# define ASN1_F_PKCS5_PBE2_SET_SCRYPT 231
|
||||||
|
# define ASN1_F_PKCS5_PBE_SET 202
|
||||||
|
# define ASN1_F_PKCS5_PBE_SET0_ALGOR 215
|
||||||
|
# define ASN1_F_PKCS5_PBKDF2_SET 219
|
||||||
|
# define ASN1_F_PKCS5_SCRYPT_SET 232
|
||||||
|
# define ASN1_F_SMIME_READ_ASN1 212
|
||||||
|
# define ASN1_F_SMIME_TEXT 213
|
||||||
|
# define ASN1_F_STABLE_GET 138
|
||||||
|
# define ASN1_F_STBL_MODULE_INIT 223
|
||||||
|
# define ASN1_F_UINT32_C2I 105
|
||||||
|
# define ASN1_F_UINT32_NEW 139
|
||||||
|
# define ASN1_F_UINT64_C2I 112
|
||||||
|
# define ASN1_F_UINT64_NEW 141
|
||||||
|
# define ASN1_F_X509_CRL_ADD0_REVOKED 169
|
||||||
|
# define ASN1_F_X509_INFO_NEW 170
|
||||||
|
# define ASN1_F_X509_NAME_ENCODE 203
|
||||||
|
# define ASN1_F_X509_NAME_EX_D2I 158
|
||||||
|
# define ASN1_F_X509_NAME_EX_NEW 171
|
||||||
|
# define ASN1_F_X509_PKEY_NEW 173
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASN1 reason codes.
|
||||||
|
*/
|
||||||
|
# define ASN1_R_ADDING_OBJECT 171
|
||||||
|
# define ASN1_R_ASN1_PARSE_ERROR 203
|
||||||
|
# define ASN1_R_ASN1_SIG_PARSE_ERROR 204
|
||||||
|
# define ASN1_R_AUX_ERROR 100
|
||||||
|
# define ASN1_R_BAD_OBJECT_HEADER 102
|
||||||
|
# define ASN1_R_BAD_TEMPLATE 230
|
||||||
|
# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214
|
||||||
|
# define ASN1_R_BN_LIB 105
|
||||||
|
# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
|
||||||
|
# define ASN1_R_BUFFER_TOO_SMALL 107
|
||||||
|
# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108
|
||||||
|
# define ASN1_R_CONTEXT_NOT_INITIALISED 217
|
||||||
|
# define ASN1_R_DATA_IS_WRONG 109
|
||||||
|
# define ASN1_R_DECODE_ERROR 110
|
||||||
|
# define ASN1_R_DEPTH_EXCEEDED 174
|
||||||
|
# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198
|
||||||
|
# define ASN1_R_ENCODE_ERROR 112
|
||||||
|
# define ASN1_R_ERROR_GETTING_TIME 173
|
||||||
|
# define ASN1_R_ERROR_LOADING_SECTION 172
|
||||||
|
# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114
|
||||||
|
# define ASN1_R_EXPECTING_AN_INTEGER 115
|
||||||
|
# define ASN1_R_EXPECTING_AN_OBJECT 116
|
||||||
|
# define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119
|
||||||
|
# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120
|
||||||
|
# define ASN1_R_FIELD_MISSING 121
|
||||||
|
# define ASN1_R_FIRST_NUM_TOO_LARGE 122
|
||||||
|
# define ASN1_R_HEADER_TOO_LONG 123
|
||||||
|
# define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175
|
||||||
|
# define ASN1_R_ILLEGAL_BOOLEAN 176
|
||||||
|
# define ASN1_R_ILLEGAL_CHARACTERS 124
|
||||||
|
# define ASN1_R_ILLEGAL_FORMAT 177
|
||||||
|
# define ASN1_R_ILLEGAL_HEX 178
|
||||||
|
# define ASN1_R_ILLEGAL_IMPLICIT_TAG 179
|
||||||
|
# define ASN1_R_ILLEGAL_INTEGER 180
|
||||||
|
# define ASN1_R_ILLEGAL_NEGATIVE_VALUE 226
|
||||||
|
# define ASN1_R_ILLEGAL_NESTED_TAGGING 181
|
||||||
|
# define ASN1_R_ILLEGAL_NULL 125
|
||||||
|
# define ASN1_R_ILLEGAL_NULL_VALUE 182
|
||||||
|
# define ASN1_R_ILLEGAL_OBJECT 183
|
||||||
|
# define ASN1_R_ILLEGAL_OPTIONAL_ANY 126
|
||||||
|
# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170
|
||||||
|
# define ASN1_R_ILLEGAL_PADDING 221
|
||||||
|
# define ASN1_R_ILLEGAL_TAGGED_ANY 127
|
||||||
|
# define ASN1_R_ILLEGAL_TIME_VALUE 184
|
||||||
|
# define ASN1_R_ILLEGAL_ZERO_CONTENT 222
|
||||||
|
# define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185
|
||||||
|
# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
|
||||||
|
# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220
|
||||||
|
# define ASN1_R_INVALID_BMPSTRING_LENGTH 129
|
||||||
|
# define ASN1_R_INVALID_DIGIT 130
|
||||||
|
# define ASN1_R_INVALID_MIME_TYPE 205
|
||||||
|
# define ASN1_R_INVALID_MODIFIER 186
|
||||||
|
# define ASN1_R_INVALID_NUMBER 187
|
||||||
|
# define ASN1_R_INVALID_OBJECT_ENCODING 216
|
||||||
|
# define ASN1_R_INVALID_SCRYPT_PARAMETERS 227
|
||||||
|
# define ASN1_R_INVALID_SEPARATOR 131
|
||||||
|
# define ASN1_R_INVALID_STRING_TABLE_VALUE 218
|
||||||
|
# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133
|
||||||
|
# define ASN1_R_INVALID_UTF8STRING 134
|
||||||
|
# define ASN1_R_INVALID_VALUE 219
|
||||||
|
# define ASN1_R_LIST_ERROR 188
|
||||||
|
# define ASN1_R_MIME_NO_CONTENT_TYPE 206
|
||||||
|
# define ASN1_R_MIME_PARSE_ERROR 207
|
||||||
|
# define ASN1_R_MIME_SIG_PARSE_ERROR 208
|
||||||
|
# define ASN1_R_MISSING_EOC 137
|
||||||
|
# define ASN1_R_MISSING_SECOND_NUMBER 138
|
||||||
|
# define ASN1_R_MISSING_VALUE 189
|
||||||
|
# define ASN1_R_MSTRING_NOT_UNIVERSAL 139
|
||||||
|
# define ASN1_R_MSTRING_WRONG_TAG 140
|
||||||
|
# define ASN1_R_NESTED_ASN1_STRING 197
|
||||||
|
# define ASN1_R_NESTED_TOO_DEEP 201
|
||||||
|
# define ASN1_R_NON_HEX_CHARACTERS 141
|
||||||
|
# define ASN1_R_NOT_ASCII_FORMAT 190
|
||||||
|
# define ASN1_R_NOT_ENOUGH_DATA 142
|
||||||
|
# define ASN1_R_NO_CONTENT_TYPE 209
|
||||||
|
# define ASN1_R_NO_MATCHING_CHOICE_TYPE 143
|
||||||
|
# define ASN1_R_NO_MULTIPART_BODY_FAILURE 210
|
||||||
|
# define ASN1_R_NO_MULTIPART_BOUNDARY 211
|
||||||
|
# define ASN1_R_NO_SIG_CONTENT_TYPE 212
|
||||||
|
# define ASN1_R_NULL_IS_WRONG_LENGTH 144
|
||||||
|
# define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191
|
||||||
|
# define ASN1_R_ODD_NUMBER_OF_CHARS 145
|
||||||
|
# define ASN1_R_SECOND_NUMBER_TOO_LARGE 147
|
||||||
|
# define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148
|
||||||
|
# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149
|
||||||
|
# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192
|
||||||
|
# define ASN1_R_SHORT_LINE 150
|
||||||
|
# define ASN1_R_SIG_INVALID_MIME_TYPE 213
|
||||||
|
# define ASN1_R_STREAMING_NOT_SUPPORTED 202
|
||||||
|
# define ASN1_R_STRING_TOO_LONG 151
|
||||||
|
# define ASN1_R_STRING_TOO_SHORT 152
|
||||||
|
# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
|
||||||
|
# define ASN1_R_TIME_NOT_ASCII_FORMAT 193
|
||||||
|
# define ASN1_R_TOO_LARGE 223
|
||||||
|
# define ASN1_R_TOO_LONG 155
|
||||||
|
# define ASN1_R_TOO_SMALL 224
|
||||||
|
# define ASN1_R_TYPE_NOT_CONSTRUCTED 156
|
||||||
|
# define ASN1_R_TYPE_NOT_PRIMITIVE 195
|
||||||
|
# define ASN1_R_UNEXPECTED_EOC 159
|
||||||
|
# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215
|
||||||
|
# define ASN1_R_UNKNOWN_FORMAT 160
|
||||||
|
# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161
|
||||||
|
# define ASN1_R_UNKNOWN_OBJECT_TYPE 162
|
||||||
|
# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163
|
||||||
|
# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199
|
||||||
|
# define ASN1_R_UNKNOWN_TAG 194
|
||||||
|
# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
|
||||||
|
# define ASN1_R_UNSUPPORTED_CIPHER 228
|
||||||
|
# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
|
||||||
|
# define ASN1_R_UNSUPPORTED_TYPE 196
|
||||||
|
# define ASN1_R_WRONG_INTEGER_TYPE 225
|
||||||
|
# define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200
|
||||||
|
# define ASN1_R_WRONG_TAG 168
|
||||||
|
|
||||||
|
#endif
|
945
lib/OpenSSL/include/openssl/asn1t.h
Normal file
@ -0,0 +1,945 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_ASN1T_H
|
||||||
|
# define HEADER_ASN1T_H
|
||||||
|
|
||||||
|
# include <stddef.h>
|
||||||
|
# include <openssl/e_os2.h>
|
||||||
|
# include <openssl/asn1.h>
|
||||||
|
|
||||||
|
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||||
|
# undef OPENSSL_EXTERN
|
||||||
|
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* ASN1 template defines, structures and functions */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||||
|
|
||||||
|
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
|
||||||
|
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
|
||||||
|
|
||||||
|
/* Macros for start and end of ASN1_ITEM definition */
|
||||||
|
|
||||||
|
# define ASN1_ITEM_start(itname) \
|
||||||
|
const ASN1_ITEM itname##_it = {
|
||||||
|
|
||||||
|
# define static_ASN1_ITEM_start(itname) \
|
||||||
|
static const ASN1_ITEM itname##_it = {
|
||||||
|
|
||||||
|
# define ASN1_ITEM_end(itname) \
|
||||||
|
};
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
|
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
|
||||||
|
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)()))
|
||||||
|
|
||||||
|
/* Macros for start and end of ASN1_ITEM definition */
|
||||||
|
|
||||||
|
# define ASN1_ITEM_start(itname) \
|
||||||
|
const ASN1_ITEM * itname##_it(void) \
|
||||||
|
{ \
|
||||||
|
static const ASN1_ITEM local_it = {
|
||||||
|
|
||||||
|
# define static_ASN1_ITEM_start(itname) \
|
||||||
|
static ASN1_ITEM_start(itname)
|
||||||
|
|
||||||
|
# define ASN1_ITEM_end(itname) \
|
||||||
|
}; \
|
||||||
|
return &local_it; \
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Macros to aid ASN1 template writing */
|
||||||
|
|
||||||
|
# define ASN1_ITEM_TEMPLATE(tname) \
|
||||||
|
static const ASN1_TEMPLATE tname##_item_tt
|
||||||
|
|
||||||
|
# define ASN1_ITEM_TEMPLATE_END(tname) \
|
||||||
|
;\
|
||||||
|
ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_PRIMITIVE,\
|
||||||
|
-1,\
|
||||||
|
&tname##_item_tt,\
|
||||||
|
0,\
|
||||||
|
NULL,\
|
||||||
|
0,\
|
||||||
|
#tname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
# define static_ASN1_ITEM_TEMPLATE_END(tname) \
|
||||||
|
;\
|
||||||
|
static_ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_PRIMITIVE,\
|
||||||
|
-1,\
|
||||||
|
&tname##_item_tt,\
|
||||||
|
0,\
|
||||||
|
NULL,\
|
||||||
|
0,\
|
||||||
|
#tname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
/* This is a ASN1 type which just embeds a template */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* This pair helps declare a SEQUENCE. We can do:
|
||||||
|
*
|
||||||
|
* ASN1_SEQUENCE(stname) = {
|
||||||
|
* ... SEQUENCE components ...
|
||||||
|
* } ASN1_SEQUENCE_END(stname)
|
||||||
|
*
|
||||||
|
* This will produce an ASN1_ITEM called stname_it
|
||||||
|
* for a structure called stname.
|
||||||
|
*
|
||||||
|
* If you want the same structure but a different
|
||||||
|
* name then use:
|
||||||
|
*
|
||||||
|
* ASN1_SEQUENCE(itname) = {
|
||||||
|
* ... SEQUENCE components ...
|
||||||
|
* } ASN1_SEQUENCE_END_name(stname, itname)
|
||||||
|
*
|
||||||
|
* This will create an item called itname_it using
|
||||||
|
* a structure called stname.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE(tname) \
|
||||||
|
static const ASN1_TEMPLATE tname##_seq_tt[]
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
|
||||||
|
|
||||||
|
# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_END_name(stname, tname) \
|
||||||
|
;\
|
||||||
|
ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_SEQUENCE,\
|
||||||
|
V_ASN1_SEQUENCE,\
|
||||||
|
tname##_seq_tt,\
|
||||||
|
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
NULL,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#tname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
# define static_ASN1_SEQUENCE_END_name(stname, tname) \
|
||||||
|
;\
|
||||||
|
static_ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_SEQUENCE,\
|
||||||
|
V_ASN1_SEQUENCE,\
|
||||||
|
tname##_seq_tt,\
|
||||||
|
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
NULL,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#stname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
# define ASN1_NDEF_SEQUENCE(tname) \
|
||||||
|
ASN1_SEQUENCE(tname)
|
||||||
|
|
||||||
|
# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
|
||||||
|
ASN1_SEQUENCE_cb(tname, cb)
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_cb(tname, cb) \
|
||||||
|
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
|
||||||
|
ASN1_SEQUENCE(tname)
|
||||||
|
|
||||||
|
# define ASN1_BROKEN_SEQUENCE(tname) \
|
||||||
|
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
|
||||||
|
ASN1_SEQUENCE(tname)
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_ref(tname, cb) \
|
||||||
|
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0}; \
|
||||||
|
ASN1_SEQUENCE(tname)
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_enc(tname, enc, cb) \
|
||||||
|
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
|
||||||
|
ASN1_SEQUENCE(tname)
|
||||||
|
|
||||||
|
# define ASN1_NDEF_SEQUENCE_END(tname) \
|
||||||
|
;\
|
||||||
|
ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||||
|
V_ASN1_SEQUENCE,\
|
||||||
|
tname##_seq_tt,\
|
||||||
|
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
NULL,\
|
||||||
|
sizeof(tname),\
|
||||||
|
#tname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
# define static_ASN1_NDEF_SEQUENCE_END(tname) \
|
||||||
|
;\
|
||||||
|
static_ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||||
|
V_ASN1_SEQUENCE,\
|
||||||
|
tname##_seq_tt,\
|
||||||
|
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
NULL,\
|
||||||
|
sizeof(tname),\
|
||||||
|
#tname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
|
||||||
|
# define static_ASN1_BROKEN_SEQUENCE_END(stname) \
|
||||||
|
static_ASN1_SEQUENCE_END_ref(stname, stname)
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
||||||
|
# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)
|
||||||
|
|
||||||
|
# define ASN1_SEQUENCE_END_ref(stname, tname) \
|
||||||
|
;\
|
||||||
|
ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_SEQUENCE,\
|
||||||
|
V_ASN1_SEQUENCE,\
|
||||||
|
tname##_seq_tt,\
|
||||||
|
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
&tname##_aux,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#tname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
# define static_ASN1_SEQUENCE_END_ref(stname, tname) \
|
||||||
|
;\
|
||||||
|
static_ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_SEQUENCE,\
|
||||||
|
V_ASN1_SEQUENCE,\
|
||||||
|
tname##_seq_tt,\
|
||||||
|
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
&tname##_aux,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#stname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
|
||||||
|
;\
|
||||||
|
ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||||
|
V_ASN1_SEQUENCE,\
|
||||||
|
tname##_seq_tt,\
|
||||||
|
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
&tname##_aux,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#stname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* This pair helps declare a CHOICE type. We can do:
|
||||||
|
*
|
||||||
|
* ASN1_CHOICE(chname) = {
|
||||||
|
* ... CHOICE options ...
|
||||||
|
* ASN1_CHOICE_END(chname)
|
||||||
|
*
|
||||||
|
* This will produce an ASN1_ITEM called chname_it
|
||||||
|
* for a structure called chname. The structure
|
||||||
|
* definition must look like this:
|
||||||
|
* typedef struct {
|
||||||
|
* int type;
|
||||||
|
* union {
|
||||||
|
* ASN1_SOMETHING *opt1;
|
||||||
|
* ASN1_SOMEOTHER *opt2;
|
||||||
|
* } value;
|
||||||
|
* } chname;
|
||||||
|
*
|
||||||
|
* the name of the selector must be 'type'.
|
||||||
|
* to use an alternative selector name use the
|
||||||
|
* ASN1_CHOICE_END_selector() version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_CHOICE(tname) \
|
||||||
|
static const ASN1_TEMPLATE tname##_ch_tt[]
|
||||||
|
|
||||||
|
# define ASN1_CHOICE_cb(tname, cb) \
|
||||||
|
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
|
||||||
|
ASN1_CHOICE(tname)
|
||||||
|
|
||||||
|
# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
|
||||||
|
|
||||||
|
# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)
|
||||||
|
|
||||||
|
# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
|
||||||
|
|
||||||
|
# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)
|
||||||
|
|
||||||
|
# define ASN1_CHOICE_END_selector(stname, tname, selname) \
|
||||||
|
;\
|
||||||
|
ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_CHOICE,\
|
||||||
|
offsetof(stname,selname) ,\
|
||||||
|
tname##_ch_tt,\
|
||||||
|
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
NULL,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#stname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
|
||||||
|
;\
|
||||||
|
static_ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_CHOICE,\
|
||||||
|
offsetof(stname,selname) ,\
|
||||||
|
tname##_ch_tt,\
|
||||||
|
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
NULL,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#stname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
# define ASN1_CHOICE_END_cb(stname, tname, selname) \
|
||||||
|
;\
|
||||||
|
ASN1_ITEM_start(tname) \
|
||||||
|
ASN1_ITYPE_CHOICE,\
|
||||||
|
offsetof(stname,selname) ,\
|
||||||
|
tname##_ch_tt,\
|
||||||
|
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||||
|
&tname##_aux,\
|
||||||
|
sizeof(stname),\
|
||||||
|
#stname \
|
||||||
|
ASN1_ITEM_end(tname)
|
||||||
|
|
||||||
|
/* This helps with the template wrapper form of ASN1_ITEM */
|
||||||
|
|
||||||
|
# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
|
||||||
|
(flags), (tag), 0,\
|
||||||
|
#name, ASN1_ITEM_ref(type) }
|
||||||
|
|
||||||
|
/* These help with SEQUENCE or CHOICE components */
|
||||||
|
|
||||||
|
/* used to declare other types */
|
||||||
|
|
||||||
|
# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
|
||||||
|
(flags), (tag), offsetof(stname, field),\
|
||||||
|
#field, ASN1_ITEM_ref(type) }
|
||||||
|
|
||||||
|
/* implicit and explicit helper macros */
|
||||||
|
|
||||||
|
# define ASN1_IMP_EX(stname, field, type, tag, ex) \
|
||||||
|
ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)
|
||||||
|
|
||||||
|
# define ASN1_EXP_EX(stname, field, type, tag, ex) \
|
||||||
|
ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)
|
||||||
|
|
||||||
|
/* Any defined by macros: the field used is in the table itself */
|
||||||
|
|
||||||
|
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||||
|
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
|
||||||
|
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
|
||||||
|
# else
|
||||||
|
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
|
||||||
|
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
|
||||||
|
# endif
|
||||||
|
/* Plain simple type */
|
||||||
|
# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
|
||||||
|
/* Embedded simple type */
|
||||||
|
# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)
|
||||||
|
|
||||||
|
/* OPTIONAL simple type */
|
||||||
|
# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||||
|
# define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type)
|
||||||
|
|
||||||
|
/* IMPLICIT tagged simple type */
|
||||||
|
# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
|
||||||
|
# define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
|
||||||
|
|
||||||
|
/* IMPLICIT tagged OPTIONAL simple type */
|
||||||
|
# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
||||||
|
# define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
|
||||||
|
|
||||||
|
/* Same as above but EXPLICIT */
|
||||||
|
|
||||||
|
# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
|
||||||
|
# define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
|
||||||
|
# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
||||||
|
# define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
|
||||||
|
|
||||||
|
/* SEQUENCE OF type */
|
||||||
|
# define ASN1_SEQUENCE_OF(stname, field, type) \
|
||||||
|
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
|
||||||
|
|
||||||
|
/* OPTIONAL SEQUENCE OF */
|
||||||
|
# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
|
||||||
|
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||||
|
|
||||||
|
/* Same as above but for SET OF */
|
||||||
|
|
||||||
|
# define ASN1_SET_OF(stname, field, type) \
|
||||||
|
ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
|
||||||
|
|
||||||
|
# define ASN1_SET_OF_OPT(stname, field, type) \
|
||||||
|
ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||||
|
|
||||||
|
/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
|
||||||
|
|
||||||
|
# define ASN1_IMP_SET_OF(stname, field, type, tag) \
|
||||||
|
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
||||||
|
|
||||||
|
# define ASN1_EXP_SET_OF(stname, field, type, tag) \
|
||||||
|
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
||||||
|
|
||||||
|
# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
|
||||||
|
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
||||||
|
|
||||||
|
# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
|
||||||
|
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
||||||
|
|
||||||
|
# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
|
||||||
|
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
||||||
|
|
||||||
|
# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
||||||
|
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
||||||
|
|
||||||
|
# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
|
||||||
|
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
||||||
|
|
||||||
|
# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
||||||
|
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
||||||
|
|
||||||
|
/* EXPLICIT using indefinite length constructed form */
|
||||||
|
# define ASN1_NDEF_EXP(stname, field, type, tag) \
|
||||||
|
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
|
||||||
|
|
||||||
|
/* EXPLICIT OPTIONAL using indefinite length constructed form */
|
||||||
|
# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
|
||||||
|
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
|
||||||
|
|
||||||
|
/* Macros for the ASN1_ADB structure */
|
||||||
|
|
||||||
|
# define ASN1_ADB(name) \
|
||||||
|
static const ASN1_ADB_TABLE name##_adbtbl[]
|
||||||
|
|
||||||
|
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||||
|
|
||||||
|
# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
|
||||||
|
;\
|
||||||
|
static const ASN1_ADB name##_adb = {\
|
||||||
|
flags,\
|
||||||
|
offsetof(name, field),\
|
||||||
|
adb_cb,\
|
||||||
|
name##_adbtbl,\
|
||||||
|
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
|
||||||
|
def,\
|
||||||
|
none\
|
||||||
|
}
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
|
# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
|
||||||
|
;\
|
||||||
|
static const ASN1_ITEM *name##_adb(void) \
|
||||||
|
{ \
|
||||||
|
static const ASN1_ADB internal_adb = \
|
||||||
|
{\
|
||||||
|
flags,\
|
||||||
|
offsetof(name, field),\
|
||||||
|
adb_cb,\
|
||||||
|
name##_adbtbl,\
|
||||||
|
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
|
||||||
|
def,\
|
||||||
|
none\
|
||||||
|
}; \
|
||||||
|
return (const ASN1_ITEM *) &internal_adb; \
|
||||||
|
} \
|
||||||
|
void dummy_function(void)
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define ADB_ENTRY(val, template) {val, template}
|
||||||
|
|
||||||
|
# define ASN1_ADB_TEMPLATE(name) \
|
||||||
|
static const ASN1_TEMPLATE name##_tt
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the ASN1 template structure that defines a wrapper round the
|
||||||
|
* actual type. It determines the actual position of the field in the value
|
||||||
|
* structure, various flags such as OPTIONAL and the field name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct ASN1_TEMPLATE_st {
|
||||||
|
unsigned long flags; /* Various flags */
|
||||||
|
long tag; /* tag, not used if no tagging */
|
||||||
|
unsigned long offset; /* Offset of this field in structure */
|
||||||
|
const char *field_name; /* Field name */
|
||||||
|
ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
|
||||||
|
|
||||||
|
# define ASN1_TEMPLATE_item(t) (t->item_ptr)
|
||||||
|
# define ASN1_TEMPLATE_adb(t) (t->item_ptr)
|
||||||
|
|
||||||
|
typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
|
||||||
|
typedef struct ASN1_ADB_st ASN1_ADB;
|
||||||
|
|
||||||
|
struct ASN1_ADB_st {
|
||||||
|
unsigned long flags; /* Various flags */
|
||||||
|
unsigned long offset; /* Offset of selector field */
|
||||||
|
int (*adb_cb)(long *psel); /* Application callback */
|
||||||
|
const ASN1_ADB_TABLE *tbl; /* Table of possible types */
|
||||||
|
long tblcount; /* Number of entries in tbl */
|
||||||
|
const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
|
||||||
|
const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ASN1_ADB_TABLE_st {
|
||||||
|
long value; /* NID for an object or value for an int */
|
||||||
|
const ASN1_TEMPLATE tt; /* item for this value */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* template flags */
|
||||||
|
|
||||||
|
/* Field is optional */
|
||||||
|
# define ASN1_TFLG_OPTIONAL (0x1)
|
||||||
|
|
||||||
|
/* Field is a SET OF */
|
||||||
|
# define ASN1_TFLG_SET_OF (0x1 << 1)
|
||||||
|
|
||||||
|
/* Field is a SEQUENCE OF */
|
||||||
|
# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special case: this refers to a SET OF that will be sorted into DER order
|
||||||
|
* when encoded *and* the corresponding STACK will be modified to match the
|
||||||
|
* new order.
|
||||||
|
*/
|
||||||
|
# define ASN1_TFLG_SET_ORDER (0x3 << 1)
|
||||||
|
|
||||||
|
/* Mask for SET OF or SEQUENCE OF */
|
||||||
|
# define ASN1_TFLG_SK_MASK (0x3 << 1)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These flags mean the tag should be taken from the tag field. If EXPLICIT
|
||||||
|
* then the underlying type is used for the inner tag.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* IMPLICIT tagging */
|
||||||
|
# define ASN1_TFLG_IMPTAG (0x1 << 3)
|
||||||
|
|
||||||
|
/* EXPLICIT tagging, inner tag from underlying type */
|
||||||
|
# define ASN1_TFLG_EXPTAG (0x2 << 3)
|
||||||
|
|
||||||
|
# define ASN1_TFLG_TAG_MASK (0x3 << 3)
|
||||||
|
|
||||||
|
/* context specific IMPLICIT */
|
||||||
|
# define ASN1_TFLG_IMPLICIT (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT)
|
||||||
|
|
||||||
|
/* context specific EXPLICIT */
|
||||||
|
# define ASN1_TFLG_EXPLICIT (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If tagging is in force these determine the type of tag to use. Otherwise
|
||||||
|
* the tag is determined by the underlying type. These values reflect the
|
||||||
|
* actual octet format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Universal tag */
|
||||||
|
# define ASN1_TFLG_UNIVERSAL (0x0<<6)
|
||||||
|
/* Application tag */
|
||||||
|
# define ASN1_TFLG_APPLICATION (0x1<<6)
|
||||||
|
/* Context specific tag */
|
||||||
|
# define ASN1_TFLG_CONTEXT (0x2<<6)
|
||||||
|
/* Private tag */
|
||||||
|
# define ASN1_TFLG_PRIVATE (0x3<<6)
|
||||||
|
|
||||||
|
# define ASN1_TFLG_TAG_CLASS (0x3<<6)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These are for ANY DEFINED BY type. In this case the 'item' field points to
|
||||||
|
* an ASN1_ADB structure which contains a table of values to decode the
|
||||||
|
* relevant type
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_TFLG_ADB_MASK (0x3<<8)
|
||||||
|
|
||||||
|
# define ASN1_TFLG_ADB_OID (0x1<<8)
|
||||||
|
|
||||||
|
# define ASN1_TFLG_ADB_INT (0x1<<9)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
|
||||||
|
* indefinite length constructed encoding to be used if required.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_TFLG_NDEF (0x1<<11)
|
||||||
|
|
||||||
|
/* Field is embedded and not a pointer */
|
||||||
|
# define ASN1_TFLG_EMBED (0x1 << 12)
|
||||||
|
|
||||||
|
/* This is the actual ASN1 item itself */
|
||||||
|
|
||||||
|
struct ASN1_ITEM_st {
|
||||||
|
char itype; /* The item type, primitive, SEQUENCE, CHOICE
|
||||||
|
* or extern */
|
||||||
|
long utype; /* underlying type */
|
||||||
|
const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
|
||||||
|
* the contents */
|
||||||
|
long tcount; /* Number of templates if SEQUENCE or CHOICE */
|
||||||
|
const void *funcs; /* functions that handle this type */
|
||||||
|
long size; /* Structure size (usually) */
|
||||||
|
const char *sname; /* Structure name */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* These are values for the itype field and
|
||||||
|
* determine how the type is interpreted.
|
||||||
|
*
|
||||||
|
* For PRIMITIVE types the underlying type
|
||||||
|
* determines the behaviour if items is NULL.
|
||||||
|
*
|
||||||
|
* Otherwise templates must contain a single
|
||||||
|
* template and the type is treated in the
|
||||||
|
* same way as the type specified in the template.
|
||||||
|
*
|
||||||
|
* For SEQUENCE types the templates field points
|
||||||
|
* to the members, the size field is the
|
||||||
|
* structure size.
|
||||||
|
*
|
||||||
|
* For CHOICE types the templates field points
|
||||||
|
* to each possible member (typically a union)
|
||||||
|
* and the 'size' field is the offset of the
|
||||||
|
* selector.
|
||||||
|
*
|
||||||
|
* The 'funcs' field is used for application
|
||||||
|
* specific functions.
|
||||||
|
*
|
||||||
|
* The EXTERN type uses a new style d2i/i2d.
|
||||||
|
* The new style should be used where possible
|
||||||
|
* because it avoids things like the d2i IMPLICIT
|
||||||
|
* hack.
|
||||||
|
*
|
||||||
|
* MSTRING is a multiple string type, it is used
|
||||||
|
* for a CHOICE of character strings where the
|
||||||
|
* actual strings all occupy an ASN1_STRING
|
||||||
|
* structure. In this case the 'utype' field
|
||||||
|
* has a special meaning, it is used as a mask
|
||||||
|
* of acceptable types using the B_ASN1 constants.
|
||||||
|
*
|
||||||
|
* NDEF_SEQUENCE is the same as SEQUENCE except
|
||||||
|
* that it will use indefinite length constructed
|
||||||
|
* encoding if requested.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ASN1_ITYPE_PRIMITIVE 0x0
|
||||||
|
|
||||||
|
# define ASN1_ITYPE_SEQUENCE 0x1
|
||||||
|
|
||||||
|
# define ASN1_ITYPE_CHOICE 0x2
|
||||||
|
|
||||||
|
# define ASN1_ITYPE_EXTERN 0x4
|
||||||
|
|
||||||
|
# define ASN1_ITYPE_MSTRING 0x5
|
||||||
|
|
||||||
|
# define ASN1_ITYPE_NDEF_SEQUENCE 0x6
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cache for ASN1 tag and length, so we don't keep re-reading it for things
|
||||||
|
* like CHOICE
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct ASN1_TLC_st {
|
||||||
|
char valid; /* Values below are valid */
|
||||||
|
int ret; /* return value */
|
||||||
|
long plen; /* length */
|
||||||
|
int ptag; /* class value */
|
||||||
|
int pclass; /* class value */
|
||||||
|
int hdrlen; /* header length */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Typedefs for ASN1 function pointers */
|
||||||
|
typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||||
|
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
||||||
|
ASN1_TLC *ctx);
|
||||||
|
|
||||||
|
typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||||
|
const ASN1_ITEM *it, int tag, int aclass);
|
||||||
|
typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||||
|
typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||||
|
|
||||||
|
typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
|
||||||
|
int indent, const char *fname,
|
||||||
|
const ASN1_PCTX *pctx);
|
||||||
|
|
||||||
|
typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,
|
||||||
|
int *putype, const ASN1_ITEM *it);
|
||||||
|
typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,
|
||||||
|
int len, int utype, char *free_cont,
|
||||||
|
const ASN1_ITEM *it);
|
||||||
|
typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,
|
||||||
|
const ASN1_ITEM *it, int indent,
|
||||||
|
const ASN1_PCTX *pctx);
|
||||||
|
|
||||||
|
typedef struct ASN1_EXTERN_FUNCS_st {
|
||||||
|
void *app_data;
|
||||||
|
ASN1_ex_new_func *asn1_ex_new;
|
||||||
|
ASN1_ex_free_func *asn1_ex_free;
|
||||||
|
ASN1_ex_free_func *asn1_ex_clear;
|
||||||
|
ASN1_ex_d2i *asn1_ex_d2i;
|
||||||
|
ASN1_ex_i2d *asn1_ex_i2d;
|
||||||
|
ASN1_ex_print_func *asn1_ex_print;
|
||||||
|
} ASN1_EXTERN_FUNCS;
|
||||||
|
|
||||||
|
typedef struct ASN1_PRIMITIVE_FUNCS_st {
|
||||||
|
void *app_data;
|
||||||
|
unsigned long flags;
|
||||||
|
ASN1_ex_new_func *prim_new;
|
||||||
|
ASN1_ex_free_func *prim_free;
|
||||||
|
ASN1_ex_free_func *prim_clear;
|
||||||
|
ASN1_primitive_c2i *prim_c2i;
|
||||||
|
ASN1_primitive_i2c *prim_i2c;
|
||||||
|
ASN1_primitive_print *prim_print;
|
||||||
|
} ASN1_PRIMITIVE_FUNCS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the ASN1_AUX structure: it handles various miscellaneous
|
||||||
|
* requirements. For example the use of reference counts and an informational
|
||||||
|
* callback. The "informational callback" is called at various points during
|
||||||
|
* the ASN1 encoding and decoding. It can be used to provide minor
|
||||||
|
* customisation of the structures used. This is most useful where the
|
||||||
|
* supplied routines *almost* do the right thing but need some extra help at
|
||||||
|
* a few points. If the callback returns zero then it is assumed a fatal
|
||||||
|
* error has occurred and the main operation should be abandoned. If major
|
||||||
|
* changes in the default behaviour are required then an external type is
|
||||||
|
* more appropriate.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
|
||||||
|
void *exarg);
|
||||||
|
|
||||||
|
typedef struct ASN1_AUX_st {
|
||||||
|
void *app_data;
|
||||||
|
int flags;
|
||||||
|
int ref_offset; /* Offset of reference value */
|
||||||
|
int ref_lock; /* Lock type to use */
|
||||||
|
ASN1_aux_cb *asn1_cb;
|
||||||
|
int enc_offset; /* Offset of ASN1_ENCODING structure */
|
||||||
|
} ASN1_AUX;
|
||||||
|
|
||||||
|
/* For print related callbacks exarg points to this structure */
|
||||||
|
typedef struct ASN1_PRINT_ARG_st {
|
||||||
|
BIO *out;
|
||||||
|
int indent;
|
||||||
|
const ASN1_PCTX *pctx;
|
||||||
|
} ASN1_PRINT_ARG;
|
||||||
|
|
||||||
|
/* For streaming related callbacks exarg points to this structure */
|
||||||
|
typedef struct ASN1_STREAM_ARG_st {
|
||||||
|
/* BIO to stream through */
|
||||||
|
BIO *out;
|
||||||
|
/* BIO with filters appended */
|
||||||
|
BIO *ndef_bio;
|
||||||
|
/* Streaming I/O boundary */
|
||||||
|
unsigned char **boundary;
|
||||||
|
} ASN1_STREAM_ARG;
|
||||||
|
|
||||||
|
/* Flags in ASN1_AUX */
|
||||||
|
|
||||||
|
/* Use a reference count */
|
||||||
|
# define ASN1_AFLG_REFCOUNT 1
|
||||||
|
/* Save the encoding of structure (useful for signatures) */
|
||||||
|
# define ASN1_AFLG_ENCODING 2
|
||||||
|
/* The Sequence length is invalid */
|
||||||
|
# define ASN1_AFLG_BROKEN 4
|
||||||
|
|
||||||
|
/* operation values for asn1_cb */
|
||||||
|
|
||||||
|
# define ASN1_OP_NEW_PRE 0
|
||||||
|
# define ASN1_OP_NEW_POST 1
|
||||||
|
# define ASN1_OP_FREE_PRE 2
|
||||||
|
# define ASN1_OP_FREE_POST 3
|
||||||
|
# define ASN1_OP_D2I_PRE 4
|
||||||
|
# define ASN1_OP_D2I_POST 5
|
||||||
|
# define ASN1_OP_I2D_PRE 6
|
||||||
|
# define ASN1_OP_I2D_POST 7
|
||||||
|
# define ASN1_OP_PRINT_PRE 8
|
||||||
|
# define ASN1_OP_PRINT_POST 9
|
||||||
|
# define ASN1_OP_STREAM_PRE 10
|
||||||
|
# define ASN1_OP_STREAM_POST 11
|
||||||
|
# define ASN1_OP_DETACHED_PRE 12
|
||||||
|
# define ASN1_OP_DETACHED_POST 13
|
||||||
|
|
||||||
|
/* Macro to implement a primitive type */
|
||||||
|
# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
|
||||||
|
# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
|
||||||
|
ASN1_ITEM_start(itname) \
|
||||||
|
ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
|
||||||
|
ASN1_ITEM_end(itname)
|
||||||
|
|
||||||
|
/* Macro to implement a multi string type */
|
||||||
|
# define IMPLEMENT_ASN1_MSTRING(itname, mask) \
|
||||||
|
ASN1_ITEM_start(itname) \
|
||||||
|
ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
|
||||||
|
ASN1_ITEM_end(itname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
|
||||||
|
ASN1_ITEM_start(sname) \
|
||||||
|
ASN1_ITYPE_EXTERN, \
|
||||||
|
tag, \
|
||||||
|
NULL, \
|
||||||
|
0, \
|
||||||
|
&fptrs, \
|
||||||
|
0, \
|
||||||
|
#sname \
|
||||||
|
ASN1_ITEM_end(sname)
|
||||||
|
|
||||||
|
/* Macro to implement standard functions in terms of ASN1_ITEM structures */
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
|
||||||
|
IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
|
||||||
|
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
|
||||||
|
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
|
||||||
|
pre stname *fname##_new(void) \
|
||||||
|
{ \
|
||||||
|
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
||||||
|
} \
|
||||||
|
pre void fname##_free(stname *a) \
|
||||||
|
{ \
|
||||||
|
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
|
||||||
|
stname *fname##_new(void) \
|
||||||
|
{ \
|
||||||
|
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
||||||
|
} \
|
||||||
|
void fname##_free(stname *a) \
|
||||||
|
{ \
|
||||||
|
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
|
||||||
|
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
||||||
|
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
||||||
|
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
|
||||||
|
{ \
|
||||||
|
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
|
||||||
|
} \
|
||||||
|
int i2d_##fname(stname *a, unsigned char **out) \
|
||||||
|
{ \
|
||||||
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
|
||||||
|
}
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
|
||||||
|
int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
|
||||||
|
{ \
|
||||||
|
return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
|
||||||
|
}
|
||||||
|
|
||||||
|
# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \
|
||||||
|
static stname *d2i_##stname(stname **a, \
|
||||||
|
const unsigned char **in, long len) \
|
||||||
|
{ \
|
||||||
|
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \
|
||||||
|
ASN1_ITEM_rptr(stname)); \
|
||||||
|
} \
|
||||||
|
static int i2d_##stname(stname *a, unsigned char **out) \
|
||||||
|
{ \
|
||||||
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, \
|
||||||
|
ASN1_ITEM_rptr(stname)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This includes evil casts to remove const: they will go away when full ASN1
|
||||||
|
* constification is done.
|
||||||
|
*/
|
||||||
|
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||||
|
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
|
||||||
|
{ \
|
||||||
|
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
|
||||||
|
} \
|
||||||
|
int i2d_##fname(const stname *a, unsigned char **out) \
|
||||||
|
{ \
|
||||||
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
|
||||||
|
}
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
|
||||||
|
stname * stname##_dup(stname *x) \
|
||||||
|
{ \
|
||||||
|
return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
|
||||||
|
}
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
|
||||||
|
IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
|
||||||
|
int fname##_print_ctx(BIO *out, stname *x, int indent, \
|
||||||
|
const ASN1_PCTX *pctx) \
|
||||||
|
{ \
|
||||||
|
return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
|
||||||
|
ASN1_ITEM_rptr(itname), pctx); \
|
||||||
|
}
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
|
||||||
|
IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
|
||||||
|
|
||||||
|
# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||||
|
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||||
|
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
|
||||||
|
|
||||||
|
/* external definitions for primitive types */
|
||||||
|
|
||||||
|
DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
|
||||||
|
DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
|
||||||
|
DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
|
||||||
|
DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
|
||||||
|
DECLARE_ASN1_ITEM(CBIGNUM)
|
||||||
|
DECLARE_ASN1_ITEM(BIGNUM)
|
||||||
|
DECLARE_ASN1_ITEM(INT32)
|
||||||
|
DECLARE_ASN1_ITEM(ZINT32)
|
||||||
|
DECLARE_ASN1_ITEM(UINT32)
|
||||||
|
DECLARE_ASN1_ITEM(ZUINT32)
|
||||||
|
DECLARE_ASN1_ITEM(INT64)
|
||||||
|
DECLARE_ASN1_ITEM(ZINT64)
|
||||||
|
DECLARE_ASN1_ITEM(UINT64)
|
||||||
|
DECLARE_ASN1_ITEM(ZUINT64)
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10200000L
|
||||||
|
/*
|
||||||
|
* LONG and ZLONG are strongly discouraged for use as stored data, as the
|
||||||
|
* underlying C type (long) differs in size depending on the architecture.
|
||||||
|
* They are designed with 32-bit longs in mind.
|
||||||
|
*/
|
||||||
|
DECLARE_ASN1_ITEM(LONG)
|
||||||
|
DECLARE_ASN1_ITEM(ZLONG)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_VALUE)
|
||||||
|
|
||||||
|
/* Functions used internally by the ASN1 code */
|
||||||
|
|
||||||
|
int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||||
|
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||||
|
|
||||||
|
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||||
|
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
||||||
|
ASN1_TLC *ctx);
|
||||||
|
|
||||||
|
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||||
|
const ASN1_ITEM *it, int tag, int aclass);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
76
lib/OpenSSL/include/openssl/async.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef HEADER_ASYNC_H
|
||||||
|
# define HEADER_ASYNC_H
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
# if defined(BASETYPES) || defined(_WINDEF_H)
|
||||||
|
/* application has to include <windows.h> to use this */
|
||||||
|
#define OSSL_ASYNC_FD HANDLE
|
||||||
|
#define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
#define OSSL_ASYNC_FD int
|
||||||
|
#define OSSL_BAD_ASYNC_FD -1
|
||||||
|
#endif
|
||||||
|
# include <openssl/asyncerr.h>
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
typedef struct async_job_st ASYNC_JOB;
|
||||||
|
typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
|
||||||
|
|
||||||
|
#define ASYNC_ERR 0
|
||||||
|
#define ASYNC_NO_JOBS 1
|
||||||
|
#define ASYNC_PAUSE 2
|
||||||
|
#define ASYNC_FINISH 3
|
||||||
|
|
||||||
|
int ASYNC_init_thread(size_t max_size, size_t init_size);
|
||||||
|
void ASYNC_cleanup_thread(void);
|
||||||
|
|
||||||
|
#ifdef OSSL_ASYNC_FD
|
||||||
|
ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
|
||||||
|
void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
|
||||||
|
int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
|
||||||
|
OSSL_ASYNC_FD fd,
|
||||||
|
void *custom_data,
|
||||||
|
void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
|
||||||
|
OSSL_ASYNC_FD, void *));
|
||||||
|
int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
|
||||||
|
OSSL_ASYNC_FD *fd, void **custom_data);
|
||||||
|
int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
|
||||||
|
size_t *numfds);
|
||||||
|
int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
|
||||||
|
size_t *numaddfds, OSSL_ASYNC_FD *delfd,
|
||||||
|
size_t *numdelfds);
|
||||||
|
int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int ASYNC_is_capable(void);
|
||||||
|
|
||||||
|
int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
|
||||||
|
int (*func)(void *), void *args, size_t size);
|
||||||
|
int ASYNC_pause_job(void);
|
||||||
|
|
||||||
|
ASYNC_JOB *ASYNC_get_current_job(void);
|
||||||
|
ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
|
||||||
|
void ASYNC_block_pause(void);
|
||||||
|
void ASYNC_unblock_pause(void);
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
42
lib/OpenSSL/include/openssl/asyncerr.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_ASYNCERR_H
|
||||||
|
# define HEADER_ASYNCERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_ASYNC_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASYNC function codes.
|
||||||
|
*/
|
||||||
|
# define ASYNC_F_ASYNC_CTX_NEW 100
|
||||||
|
# define ASYNC_F_ASYNC_INIT_THREAD 101
|
||||||
|
# define ASYNC_F_ASYNC_JOB_NEW 102
|
||||||
|
# define ASYNC_F_ASYNC_PAUSE_JOB 103
|
||||||
|
# define ASYNC_F_ASYNC_START_FUNC 104
|
||||||
|
# define ASYNC_F_ASYNC_START_JOB 105
|
||||||
|
# define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD 106
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASYNC reason codes.
|
||||||
|
*/
|
||||||
|
# define ASYNC_R_FAILED_TO_SET_POOL 101
|
||||||
|
# define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102
|
||||||
|
# define ASYNC_R_INIT_FAILED 105
|
||||||
|
# define ASYNC_R_INVALID_POOL_SIZE 103
|
||||||
|
|
||||||
|
#endif
|
801
lib/OpenSSL/include/openssl/bio.h
Normal file
@ -0,0 +1,801 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_BIO_H
|
||||||
|
# define HEADER_BIO_H
|
||||||
|
|
||||||
|
# include <openssl/e_os2.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
# include <stdio.h>
|
||||||
|
# endif
|
||||||
|
# include <stdarg.h>
|
||||||
|
|
||||||
|
# include <openssl/crypto.h>
|
||||||
|
# include <openssl/bioerr.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* There are the classes of BIOs */
|
||||||
|
# define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
|
||||||
|
# define BIO_TYPE_FILTER 0x0200
|
||||||
|
# define BIO_TYPE_SOURCE_SINK 0x0400
|
||||||
|
|
||||||
|
/* These are the 'types' of BIOs */
|
||||||
|
# define BIO_TYPE_NONE 0
|
||||||
|
# define BIO_TYPE_MEM ( 1|BIO_TYPE_SOURCE_SINK)
|
||||||
|
# define BIO_TYPE_FILE ( 2|BIO_TYPE_SOURCE_SINK)
|
||||||
|
|
||||||
|
# define BIO_TYPE_FD ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||||
|
# define BIO_TYPE_SOCKET ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||||
|
# define BIO_TYPE_NULL ( 6|BIO_TYPE_SOURCE_SINK)
|
||||||
|
# define BIO_TYPE_SSL ( 7|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_MD ( 8|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_BUFFER ( 9|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_CIPHER (10|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_BASE64 (11|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_CONNECT (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||||
|
# define BIO_TYPE_ACCEPT (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||||
|
|
||||||
|
# define BIO_TYPE_NBIO_TEST (16|BIO_TYPE_FILTER)/* server proxy BIO */
|
||||||
|
# define BIO_TYPE_NULL_FILTER (17|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_BIO (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */
|
||||||
|
# define BIO_TYPE_LINEBUFFER (20|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_DGRAM (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||||
|
# define BIO_TYPE_ASN1 (22|BIO_TYPE_FILTER)
|
||||||
|
# define BIO_TYPE_COMP (23|BIO_TYPE_FILTER)
|
||||||
|
# ifndef OPENSSL_NO_SCTP
|
||||||
|
# define BIO_TYPE_DGRAM_SCTP (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#define BIO_TYPE_START 128
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
|
||||||
|
* BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||||
|
*/
|
||||||
|
# define BIO_NOCLOSE 0x00
|
||||||
|
# define BIO_CLOSE 0x01
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These are used in the following macros and are passed to BIO_ctrl()
|
||||||
|
*/
|
||||||
|
# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */
|
||||||
|
# define BIO_CTRL_EOF 2/* opt - are we at the eof */
|
||||||
|
# define BIO_CTRL_INFO 3/* opt - extra tit-bits */
|
||||||
|
# define BIO_CTRL_SET 4/* man - set the 'IO' type */
|
||||||
|
# define BIO_CTRL_GET 5/* man - get the 'IO' type */
|
||||||
|
# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */
|
||||||
|
# define BIO_CTRL_POP 7/* opt - internal, used to signify change */
|
||||||
|
# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */
|
||||||
|
# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */
|
||||||
|
# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */
|
||||||
|
# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */
|
||||||
|
# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */
|
||||||
|
# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */
|
||||||
|
# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */
|
||||||
|
# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */
|
||||||
|
|
||||||
|
# define BIO_CTRL_PEEK 29/* BIO_f_buffer special */
|
||||||
|
# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */
|
||||||
|
|
||||||
|
/* dgram BIO stuff */
|
||||||
|
# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */
|
||||||
|
# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected
|
||||||
|
* socket to be passed in */
|
||||||
|
# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */
|
||||||
|
# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */
|
||||||
|
# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */
|
||||||
|
# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */
|
||||||
|
|
||||||
|
# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */
|
||||||
|
# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */
|
||||||
|
|
||||||
|
/* #ifdef IP_MTU_DISCOVER */
|
||||||
|
# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */
|
||||||
|
# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47
|
||||||
|
# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */
|
||||||
|
# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU.
|
||||||
|
* want to use this if asking
|
||||||
|
* the kernel fails */
|
||||||
|
|
||||||
|
# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was
|
||||||
|
* exceed in the previous write
|
||||||
|
* operation */
|
||||||
|
|
||||||
|
# define BIO_CTRL_DGRAM_GET_PEER 46
|
||||||
|
# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */
|
||||||
|
|
||||||
|
# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout
|
||||||
|
* to adjust socket timeouts */
|
||||||
|
# define BIO_CTRL_DGRAM_SET_DONT_FRAG 48
|
||||||
|
|
||||||
|
# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49
|
||||||
|
|
||||||
|
/* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50
|
||||||
|
# ifndef OPENSSL_NO_SCTP
|
||||||
|
/* SCTP stuff */
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65
|
||||||
|
# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define BIO_CTRL_DGRAM_SET_PEEK_MODE 71
|
||||||
|
|
||||||
|
/* modifiers */
|
||||||
|
# define BIO_FP_READ 0x02
|
||||||
|
# define BIO_FP_WRITE 0x04
|
||||||
|
# define BIO_FP_APPEND 0x08
|
||||||
|
# define BIO_FP_TEXT 0x10
|
||||||
|
|
||||||
|
# define BIO_FLAGS_READ 0x01
|
||||||
|
# define BIO_FLAGS_WRITE 0x02
|
||||||
|
# define BIO_FLAGS_IO_SPECIAL 0x04
|
||||||
|
# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
|
||||||
|
# define BIO_FLAGS_SHOULD_RETRY 0x08
|
||||||
|
# ifndef BIO_FLAGS_UPLINK
|
||||||
|
/*
|
||||||
|
* "UPLINK" flag denotes file descriptors provided by application. It
|
||||||
|
* defaults to 0, as most platforms don't require UPLINK interface.
|
||||||
|
*/
|
||||||
|
# define BIO_FLAGS_UPLINK 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define BIO_FLAGS_BASE64_NO_NL 0x100
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is used with memory BIOs:
|
||||||
|
* BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way;
|
||||||
|
* BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.
|
||||||
|
*/
|
||||||
|
# define BIO_FLAGS_MEM_RDONLY 0x200
|
||||||
|
# define BIO_FLAGS_NONCLEAR_RST 0x400
|
||||||
|
# define BIO_FLAGS_IN_EOF 0x800
|
||||||
|
|
||||||
|
typedef union bio_addr_st BIO_ADDR;
|
||||||
|
typedef struct bio_addrinfo_st BIO_ADDRINFO;
|
||||||
|
|
||||||
|
int BIO_get_new_index(void);
|
||||||
|
void BIO_set_flags(BIO *b, int flags);
|
||||||
|
int BIO_test_flags(const BIO *b, int flags);
|
||||||
|
void BIO_clear_flags(BIO *b, int flags);
|
||||||
|
|
||||||
|
# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
|
||||||
|
# define BIO_set_retry_special(b) \
|
||||||
|
BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
|
||||||
|
# define BIO_set_retry_read(b) \
|
||||||
|
BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
|
||||||
|
# define BIO_set_retry_write(b) \
|
||||||
|
BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
|
||||||
|
|
||||||
|
/* These are normally used internally in BIOs */
|
||||||
|
# define BIO_clear_retry_flags(b) \
|
||||||
|
BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||||
|
# define BIO_get_retry_flags(b) \
|
||||||
|
BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||||
|
|
||||||
|
/* These should be used by the application to tell why we should retry */
|
||||||
|
# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ)
|
||||||
|
# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE)
|
||||||
|
# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
|
||||||
|
# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS)
|
||||||
|
# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The next three are used in conjunction with the BIO_should_io_special()
|
||||||
|
* condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int
|
||||||
|
* *reason); will walk the BIO stack and return the 'reason' for the special
|
||||||
|
* and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return
|
||||||
|
* the code.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Returned from the SSL bio when the certificate retrieval code had an error
|
||||||
|
*/
|
||||||
|
# define BIO_RR_SSL_X509_LOOKUP 0x01
|
||||||
|
/* Returned from the connect BIO when a connect would have blocked */
|
||||||
|
# define BIO_RR_CONNECT 0x02
|
||||||
|
/* Returned from the accept BIO when an accept would have blocked */
|
||||||
|
# define BIO_RR_ACCEPT 0x03
|
||||||
|
|
||||||
|
/* These are passed by the BIO callback */
|
||||||
|
# define BIO_CB_FREE 0x01
|
||||||
|
# define BIO_CB_READ 0x02
|
||||||
|
# define BIO_CB_WRITE 0x03
|
||||||
|
# define BIO_CB_PUTS 0x04
|
||||||
|
# define BIO_CB_GETS 0x05
|
||||||
|
# define BIO_CB_CTRL 0x06
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The callback is called before and after the underling operation, The
|
||||||
|
* BIO_CB_RETURN flag indicates if it is after the call
|
||||||
|
*/
|
||||||
|
# define BIO_CB_RETURN 0x80
|
||||||
|
# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)
|
||||||
|
# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
|
||||||
|
# define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
|
||||||
|
|
||||||
|
typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
|
||||||
|
long argl, long ret);
|
||||||
|
typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,
|
||||||
|
size_t len, int argi,
|
||||||
|
long argl, int ret, size_t *processed);
|
||||||
|
BIO_callback_fn BIO_get_callback(const BIO *b);
|
||||||
|
void BIO_set_callback(BIO *b, BIO_callback_fn callback);
|
||||||
|
|
||||||
|
BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);
|
||||||
|
void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);
|
||||||
|
|
||||||
|
char *BIO_get_callback_arg(const BIO *b);
|
||||||
|
void BIO_set_callback_arg(BIO *b, char *arg);
|
||||||
|
|
||||||
|
typedef struct bio_method_st BIO_METHOD;
|
||||||
|
|
||||||
|
const char *BIO_method_name(const BIO *b);
|
||||||
|
int BIO_method_type(const BIO *b);
|
||||||
|
|
||||||
|
typedef int BIO_info_cb(BIO *, int, int);
|
||||||
|
typedef BIO_info_cb bio_info_cb; /* backward compatibility */
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(BIO)
|
||||||
|
|
||||||
|
/* Prefix and suffix callback in ASN1 BIO */
|
||||||
|
typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,
|
||||||
|
void *parg);
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_SCTP
|
||||||
|
/* SCTP parameter structs */
|
||||||
|
struct bio_dgram_sctp_sndinfo {
|
||||||
|
uint16_t snd_sid;
|
||||||
|
uint16_t snd_flags;
|
||||||
|
uint32_t snd_ppid;
|
||||||
|
uint32_t snd_context;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bio_dgram_sctp_rcvinfo {
|
||||||
|
uint16_t rcv_sid;
|
||||||
|
uint16_t rcv_ssn;
|
||||||
|
uint16_t rcv_flags;
|
||||||
|
uint32_t rcv_ppid;
|
||||||
|
uint32_t rcv_tsn;
|
||||||
|
uint32_t rcv_cumtsn;
|
||||||
|
uint32_t rcv_context;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bio_dgram_sctp_prinfo {
|
||||||
|
uint16_t pr_policy;
|
||||||
|
uint32_t pr_value;
|
||||||
|
};
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* #define BIO_CONN_get_param_hostname BIO_ctrl
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define BIO_C_SET_CONNECT 100
|
||||||
|
# define BIO_C_DO_STATE_MACHINE 101
|
||||||
|
# define BIO_C_SET_NBIO 102
|
||||||
|
/* # define BIO_C_SET_PROXY_PARAM 103 */
|
||||||
|
# define BIO_C_SET_FD 104
|
||||||
|
# define BIO_C_GET_FD 105
|
||||||
|
# define BIO_C_SET_FILE_PTR 106
|
||||||
|
# define BIO_C_GET_FILE_PTR 107
|
||||||
|
# define BIO_C_SET_FILENAME 108
|
||||||
|
# define BIO_C_SET_SSL 109
|
||||||
|
# define BIO_C_GET_SSL 110
|
||||||
|
# define BIO_C_SET_MD 111
|
||||||
|
# define BIO_C_GET_MD 112
|
||||||
|
# define BIO_C_GET_CIPHER_STATUS 113
|
||||||
|
# define BIO_C_SET_BUF_MEM 114
|
||||||
|
# define BIO_C_GET_BUF_MEM_PTR 115
|
||||||
|
# define BIO_C_GET_BUFF_NUM_LINES 116
|
||||||
|
# define BIO_C_SET_BUFF_SIZE 117
|
||||||
|
# define BIO_C_SET_ACCEPT 118
|
||||||
|
# define BIO_C_SSL_MODE 119
|
||||||
|
# define BIO_C_GET_MD_CTX 120
|
||||||
|
/* # define BIO_C_GET_PROXY_PARAM 121 */
|
||||||
|
# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */
|
||||||
|
# define BIO_C_GET_CONNECT 123
|
||||||
|
# define BIO_C_GET_ACCEPT 124
|
||||||
|
# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125
|
||||||
|
# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126
|
||||||
|
# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127
|
||||||
|
# define BIO_C_FILE_SEEK 128
|
||||||
|
# define BIO_C_GET_CIPHER_CTX 129
|
||||||
|
# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input
|
||||||
|
* value */
|
||||||
|
# define BIO_C_SET_BIND_MODE 131
|
||||||
|
# define BIO_C_GET_BIND_MODE 132
|
||||||
|
# define BIO_C_FILE_TELL 133
|
||||||
|
# define BIO_C_GET_SOCKS 134
|
||||||
|
# define BIO_C_SET_SOCKS 135
|
||||||
|
|
||||||
|
# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */
|
||||||
|
# define BIO_C_GET_WRITE_BUF_SIZE 137
|
||||||
|
# define BIO_C_MAKE_BIO_PAIR 138
|
||||||
|
# define BIO_C_DESTROY_BIO_PAIR 139
|
||||||
|
# define BIO_C_GET_WRITE_GUARANTEE 140
|
||||||
|
# define BIO_C_GET_READ_REQUEST 141
|
||||||
|
# define BIO_C_SHUTDOWN_WR 142
|
||||||
|
# define BIO_C_NREAD0 143
|
||||||
|
# define BIO_C_NREAD 144
|
||||||
|
# define BIO_C_NWRITE0 145
|
||||||
|
# define BIO_C_NWRITE 146
|
||||||
|
# define BIO_C_RESET_READ_REQUEST 147
|
||||||
|
# define BIO_C_SET_MD_CTX 148
|
||||||
|
|
||||||
|
# define BIO_C_SET_PREFIX 149
|
||||||
|
# define BIO_C_GET_PREFIX 150
|
||||||
|
# define BIO_C_SET_SUFFIX 151
|
||||||
|
# define BIO_C_GET_SUFFIX 152
|
||||||
|
|
||||||
|
# define BIO_C_SET_EX_ARG 153
|
||||||
|
# define BIO_C_GET_EX_ARG 154
|
||||||
|
|
||||||
|
# define BIO_C_SET_CONNECT_MODE 155
|
||||||
|
|
||||||
|
# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
|
||||||
|
# define BIO_get_app_data(s) BIO_get_ex_data(s,0)
|
||||||
|
|
||||||
|
# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_SOCK
|
||||||
|
/* IP families we support, for BIO_s_connect() and BIO_s_accept() */
|
||||||
|
/* Note: the underlying operating system may not support some of them */
|
||||||
|
# define BIO_FAMILY_IPV4 4
|
||||||
|
# define BIO_FAMILY_IPV6 6
|
||||||
|
# define BIO_FAMILY_IPANY 256
|
||||||
|
|
||||||
|
/* BIO_s_connect() */
|
||||||
|
# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \
|
||||||
|
(char *)(name))
|
||||||
|
# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1, \
|
||||||
|
(char *)(port))
|
||||||
|
# define BIO_set_conn_address(b,addr) BIO_ctrl(b,BIO_C_SET_CONNECT,2, \
|
||||||
|
(char *)(addr))
|
||||||
|
# define BIO_set_conn_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f)
|
||||||
|
# define BIO_get_conn_hostname(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0))
|
||||||
|
# define BIO_get_conn_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1))
|
||||||
|
# define BIO_get_conn_address(b) ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2))
|
||||||
|
# define BIO_get_conn_ip_family(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)
|
||||||
|
# define BIO_set_conn_mode(b,n) BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)
|
||||||
|
|
||||||
|
/* BIO_s_accept() */
|
||||||
|
# define BIO_set_accept_name(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \
|
||||||
|
(char *)(name))
|
||||||
|
# define BIO_set_accept_port(b,port) BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \
|
||||||
|
(char *)(port))
|
||||||
|
# define BIO_get_accept_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0))
|
||||||
|
# define BIO_get_accept_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1))
|
||||||
|
# define BIO_get_peer_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2))
|
||||||
|
# define BIO_get_peer_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3))
|
||||||
|
/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
|
||||||
|
# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL)
|
||||||
|
# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \
|
||||||
|
(char *)(bio))
|
||||||
|
# define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f)
|
||||||
|
# define BIO_get_accept_ip_family(b) BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL)
|
||||||
|
|
||||||
|
/* Aliases kept for backward compatibility */
|
||||||
|
# define BIO_BIND_NORMAL 0
|
||||||
|
# define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR
|
||||||
|
# define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR
|
||||||
|
# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
|
||||||
|
# define BIO_get_bind_mode(b) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
|
||||||
|
|
||||||
|
/* BIO_s_accept() and BIO_s_connect() */
|
||||||
|
# define BIO_do_connect(b) BIO_do_handshake(b)
|
||||||
|
# define BIO_do_accept(b) BIO_do_handshake(b)
|
||||||
|
# endif /* OPENSSL_NO_SOCK */
|
||||||
|
|
||||||
|
# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
|
||||||
|
|
||||||
|
/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */
|
||||||
|
# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
|
||||||
|
# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c))
|
||||||
|
|
||||||
|
/* BIO_s_file() */
|
||||||
|
# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp))
|
||||||
|
# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp))
|
||||||
|
|
||||||
|
/* BIO_s_fd() and BIO_s_file() */
|
||||||
|
# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
|
||||||
|
# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* name is cast to lose const, but might be better to route through a
|
||||||
|
* function so we can do it safely
|
||||||
|
*/
|
||||||
|
# ifdef CONST_STRICT
|
||||||
|
/*
|
||||||
|
* If you are wondering why this isn't defined, its because CONST_STRICT is
|
||||||
|
* purely a compile-time kludge to allow const to be checked.
|
||||||
|
*/
|
||||||
|
int BIO_read_filename(BIO *b, const char *name);
|
||||||
|
# else
|
||||||
|
# define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||||
|
BIO_CLOSE|BIO_FP_READ,(char *)(name))
|
||||||
|
# endif
|
||||||
|
# define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||||
|
BIO_CLOSE|BIO_FP_WRITE,name)
|
||||||
|
# define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||||
|
BIO_CLOSE|BIO_FP_APPEND,name)
|
||||||
|
# define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||||
|
BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WARNING WARNING, this ups the reference count on the read bio of the SSL
|
||||||
|
* structure. This is because the ssl read BIO is now pointed to by the
|
||||||
|
* next_bio field in the bio. So when you free the BIO, make sure you are
|
||||||
|
* doing a BIO_free_all() to catch the underlying BIO.
|
||||||
|
*/
|
||||||
|
# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl))
|
||||||
|
# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp))
|
||||||
|
# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
|
||||||
|
# define BIO_set_ssl_renegotiate_bytes(b,num) \
|
||||||
|
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)
|
||||||
|
# define BIO_get_num_renegotiates(b) \
|
||||||
|
BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)
|
||||||
|
# define BIO_set_ssl_renegotiate_timeout(b,seconds) \
|
||||||
|
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)
|
||||||
|
|
||||||
|
/* defined in evp.h */
|
||||||
|
/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */
|
||||||
|
|
||||||
|
# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp))
|
||||||
|
# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm))
|
||||||
|
# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \
|
||||||
|
(char *)(pp))
|
||||||
|
# define BIO_set_mem_eof_return(b,v) \
|
||||||
|
BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
|
||||||
|
|
||||||
|
/* For the BIO_f_buffer() type */
|
||||||
|
# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
|
||||||
|
# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
|
||||||
|
# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
|
||||||
|
# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
|
||||||
|
# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
|
||||||
|
|
||||||
|
/* Don't use the next one unless you know what you are doing :-) */
|
||||||
|
# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
|
||||||
|
|
||||||
|
# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
|
||||||
|
# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
|
||||||
|
# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
|
||||||
|
# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
|
||||||
|
# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
|
||||||
|
# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
|
||||||
|
/* ...pending macros have inappropriate return type */
|
||||||
|
size_t BIO_ctrl_pending(BIO *b);
|
||||||
|
size_t BIO_ctrl_wpending(BIO *b);
|
||||||
|
# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
|
||||||
|
# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
|
||||||
|
cbp)
|
||||||
|
# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
|
||||||
|
|
||||||
|
/* For the BIO_f_buffer() type */
|
||||||
|
# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
|
||||||
|
# define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s))
|
||||||
|
|
||||||
|
/* For BIO_s_bio() */
|
||||||
|
# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
|
||||||
|
# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
|
||||||
|
# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
|
||||||
|
# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
|
||||||
|
# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
|
||||||
|
/* macros with inappropriate type -- but ...pending macros use int too: */
|
||||||
|
# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
|
||||||
|
# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
|
||||||
|
size_t BIO_ctrl_get_write_guarantee(BIO *b);
|
||||||
|
size_t BIO_ctrl_get_read_request(BIO *b);
|
||||||
|
int BIO_ctrl_reset_read_request(BIO *b);
|
||||||
|
|
||||||
|
/* ctrl macros for dgram */
|
||||||
|
# define BIO_ctrl_dgram_connect(b,peer) \
|
||||||
|
(int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer))
|
||||||
|
# define BIO_ctrl_set_connected(b,peer) \
|
||||||
|
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer))
|
||||||
|
# define BIO_dgram_recv_timedout(b) \
|
||||||
|
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
|
||||||
|
# define BIO_dgram_send_timedout(b) \
|
||||||
|
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
|
||||||
|
# define BIO_dgram_get_peer(b,peer) \
|
||||||
|
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer))
|
||||||
|
# define BIO_dgram_set_peer(b,peer) \
|
||||||
|
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer))
|
||||||
|
# define BIO_dgram_get_mtu_overhead(b) \
|
||||||
|
(unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
|
||||||
|
|
||||||
|
#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||||
|
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef)
|
||||||
|
int BIO_set_ex_data(BIO *bio, int idx, void *data);
|
||||||
|
void *BIO_get_ex_data(BIO *bio, int idx);
|
||||||
|
uint64_t BIO_number_read(BIO *bio);
|
||||||
|
uint64_t BIO_number_written(BIO *bio);
|
||||||
|
|
||||||
|
/* For BIO_f_asn1() */
|
||||||
|
int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
|
||||||
|
asn1_ps_func *prefix_free);
|
||||||
|
int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
|
||||||
|
asn1_ps_func **pprefix_free);
|
||||||
|
int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
|
||||||
|
asn1_ps_func *suffix_free);
|
||||||
|
int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
|
||||||
|
asn1_ps_func **psuffix_free);
|
||||||
|
|
||||||
|
const BIO_METHOD *BIO_s_file(void);
|
||||||
|
BIO *BIO_new_file(const char *filename, const char *mode);
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
BIO *BIO_new_fp(FILE *stream, int close_flag);
|
||||||
|
# endif
|
||||||
|
BIO *BIO_new(const BIO_METHOD *type);
|
||||||
|
int BIO_free(BIO *a);
|
||||||
|
void BIO_set_data(BIO *a, void *ptr);
|
||||||
|
void *BIO_get_data(BIO *a);
|
||||||
|
void BIO_set_init(BIO *a, int init);
|
||||||
|
int BIO_get_init(BIO *a);
|
||||||
|
void BIO_set_shutdown(BIO *a, int shut);
|
||||||
|
int BIO_get_shutdown(BIO *a);
|
||||||
|
void BIO_vfree(BIO *a);
|
||||||
|
int BIO_up_ref(BIO *a);
|
||||||
|
int BIO_read(BIO *b, void *data, int dlen);
|
||||||
|
int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
|
||||||
|
int BIO_gets(BIO *bp, char *buf, int size);
|
||||||
|
int BIO_write(BIO *b, const void *data, int dlen);
|
||||||
|
int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
|
||||||
|
int BIO_puts(BIO *bp, const char *buf);
|
||||||
|
int BIO_indent(BIO *b, int indent, int max);
|
||||||
|
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
|
||||||
|
long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
|
||||||
|
void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
|
||||||
|
long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
|
||||||
|
BIO *BIO_push(BIO *b, BIO *append);
|
||||||
|
BIO *BIO_pop(BIO *b);
|
||||||
|
void BIO_free_all(BIO *a);
|
||||||
|
BIO *BIO_find_type(BIO *b, int bio_type);
|
||||||
|
BIO *BIO_next(BIO *b);
|
||||||
|
void BIO_set_next(BIO *b, BIO *next);
|
||||||
|
BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
|
||||||
|
int BIO_get_retry_reason(BIO *bio);
|
||||||
|
void BIO_set_retry_reason(BIO *bio, int reason);
|
||||||
|
BIO *BIO_dup_chain(BIO *in);
|
||||||
|
|
||||||
|
int BIO_nread0(BIO *bio, char **buf);
|
||||||
|
int BIO_nread(BIO *bio, char **buf, int num);
|
||||||
|
int BIO_nwrite0(BIO *bio, char **buf);
|
||||||
|
int BIO_nwrite(BIO *bio, char **buf, int num);
|
||||||
|
|
||||||
|
long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
|
||||||
|
long argl, long ret);
|
||||||
|
|
||||||
|
const BIO_METHOD *BIO_s_mem(void);
|
||||||
|
const BIO_METHOD *BIO_s_secmem(void);
|
||||||
|
BIO *BIO_new_mem_buf(const void *buf, int len);
|
||||||
|
# ifndef OPENSSL_NO_SOCK
|
||||||
|
const BIO_METHOD *BIO_s_socket(void);
|
||||||
|
const BIO_METHOD *BIO_s_connect(void);
|
||||||
|
const BIO_METHOD *BIO_s_accept(void);
|
||||||
|
# endif
|
||||||
|
const BIO_METHOD *BIO_s_fd(void);
|
||||||
|
const BIO_METHOD *BIO_s_log(void);
|
||||||
|
const BIO_METHOD *BIO_s_bio(void);
|
||||||
|
const BIO_METHOD *BIO_s_null(void);
|
||||||
|
const BIO_METHOD *BIO_f_null(void);
|
||||||
|
const BIO_METHOD *BIO_f_buffer(void);
|
||||||
|
const BIO_METHOD *BIO_f_linebuffer(void);
|
||||||
|
const BIO_METHOD *BIO_f_nbio_test(void);
|
||||||
|
# ifndef OPENSSL_NO_DGRAM
|
||||||
|
const BIO_METHOD *BIO_s_datagram(void);
|
||||||
|
int BIO_dgram_non_fatal_error(int error);
|
||||||
|
BIO *BIO_new_dgram(int fd, int close_flag);
|
||||||
|
# ifndef OPENSSL_NO_SCTP
|
||||||
|
const BIO_METHOD *BIO_s_datagram_sctp(void);
|
||||||
|
BIO *BIO_new_dgram_sctp(int fd, int close_flag);
|
||||||
|
int BIO_dgram_is_sctp(BIO *bio);
|
||||||
|
int BIO_dgram_sctp_notification_cb(BIO *b,
|
||||||
|
void (*handle_notifications) (BIO *bio,
|
||||||
|
void *context,
|
||||||
|
void *buf),
|
||||||
|
void *context);
|
||||||
|
int BIO_dgram_sctp_wait_for_dry(BIO *b);
|
||||||
|
int BIO_dgram_sctp_msg_waiting(BIO *b);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_SOCK
|
||||||
|
int BIO_sock_should_retry(int i);
|
||||||
|
int BIO_sock_non_fatal_error(int error);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
int BIO_fd_should_retry(int i);
|
||||||
|
int BIO_fd_non_fatal_error(int error);
|
||||||
|
int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||||
|
void *u, const char *s, int len);
|
||||||
|
int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||||
|
void *u, const char *s, int len, int indent);
|
||||||
|
int BIO_dump(BIO *b, const char *bytes, int len);
|
||||||
|
int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
int BIO_dump_fp(FILE *fp, const char *s, int len);
|
||||||
|
int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
|
||||||
|
# endif
|
||||||
|
int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,
|
||||||
|
int datalen);
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_SOCK
|
||||||
|
BIO_ADDR *BIO_ADDR_new(void);
|
||||||
|
int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
|
||||||
|
const void *where, size_t wherelen, unsigned short port);
|
||||||
|
void BIO_ADDR_free(BIO_ADDR *);
|
||||||
|
void BIO_ADDR_clear(BIO_ADDR *ap);
|
||||||
|
int BIO_ADDR_family(const BIO_ADDR *ap);
|
||||||
|
int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
|
||||||
|
unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
|
||||||
|
char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
|
||||||
|
char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
|
||||||
|
char *BIO_ADDR_path_string(const BIO_ADDR *ap);
|
||||||
|
|
||||||
|
const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);
|
||||||
|
int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);
|
||||||
|
int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);
|
||||||
|
int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);
|
||||||
|
const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);
|
||||||
|
void BIO_ADDRINFO_free(BIO_ADDRINFO *bai);
|
||||||
|
|
||||||
|
enum BIO_hostserv_priorities {
|
||||||
|
BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
|
||||||
|
};
|
||||||
|
int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
|
||||||
|
enum BIO_hostserv_priorities hostserv_prio);
|
||||||
|
enum BIO_lookup_type {
|
||||||
|
BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER
|
||||||
|
};
|
||||||
|
int BIO_lookup(const char *host, const char *service,
|
||||||
|
enum BIO_lookup_type lookup_type,
|
||||||
|
int family, int socktype, BIO_ADDRINFO **res);
|
||||||
|
int BIO_lookup_ex(const char *host, const char *service,
|
||||||
|
int lookup_type, int family, int socktype, int protocol,
|
||||||
|
BIO_ADDRINFO **res);
|
||||||
|
int BIO_sock_error(int sock);
|
||||||
|
int BIO_socket_ioctl(int fd, long type, void *arg);
|
||||||
|
int BIO_socket_nbio(int fd, int mode);
|
||||||
|
int BIO_sock_init(void);
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# define BIO_sock_cleanup() while(0) continue
|
||||||
|
# endif
|
||||||
|
int BIO_set_tcp_ndelay(int sock, int turn_on);
|
||||||
|
|
||||||
|
DEPRECATEDIN_1_1_0(struct hostent *BIO_gethostbyname(const char *name))
|
||||||
|
DEPRECATEDIN_1_1_0(int BIO_get_port(const char *str, unsigned short *port_ptr))
|
||||||
|
DEPRECATEDIN_1_1_0(int BIO_get_host_ip(const char *str, unsigned char *ip))
|
||||||
|
DEPRECATEDIN_1_1_0(int BIO_get_accept_socket(char *host_port, int mode))
|
||||||
|
DEPRECATEDIN_1_1_0(int BIO_accept(int sock, char **ip_port))
|
||||||
|
|
||||||
|
union BIO_sock_info_u {
|
||||||
|
BIO_ADDR *addr;
|
||||||
|
};
|
||||||
|
enum BIO_sock_info_type {
|
||||||
|
BIO_SOCK_INFO_ADDRESS
|
||||||
|
};
|
||||||
|
int BIO_sock_info(int sock,
|
||||||
|
enum BIO_sock_info_type type, union BIO_sock_info_u *info);
|
||||||
|
|
||||||
|
# define BIO_SOCK_REUSEADDR 0x01
|
||||||
|
# define BIO_SOCK_V6_ONLY 0x02
|
||||||
|
# define BIO_SOCK_KEEPALIVE 0x04
|
||||||
|
# define BIO_SOCK_NONBLOCK 0x08
|
||||||
|
# define BIO_SOCK_NODELAY 0x10
|
||||||
|
|
||||||
|
int BIO_socket(int domain, int socktype, int protocol, int options);
|
||||||
|
int BIO_connect(int sock, const BIO_ADDR *addr, int options);
|
||||||
|
int BIO_bind(int sock, const BIO_ADDR *addr, int options);
|
||||||
|
int BIO_listen(int sock, const BIO_ADDR *addr, int options);
|
||||||
|
int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options);
|
||||||
|
int BIO_closesocket(int sock);
|
||||||
|
|
||||||
|
BIO *BIO_new_socket(int sock, int close_flag);
|
||||||
|
BIO *BIO_new_connect(const char *host_port);
|
||||||
|
BIO *BIO_new_accept(const char *host_port);
|
||||||
|
# endif /* OPENSSL_NO_SOCK*/
|
||||||
|
|
||||||
|
BIO *BIO_new_fd(int fd, int close_flag);
|
||||||
|
|
||||||
|
int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
|
||||||
|
BIO **bio2, size_t writebuf2);
|
||||||
|
/*
|
||||||
|
* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
|
||||||
|
* Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default
|
||||||
|
* value.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void BIO_copy_next_retry(BIO *b);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define ossl_bio__attr__(x)
|
||||||
|
# if defined(__GNUC__) && defined(__STDC_VERSION__) \
|
||||||
|
&& !defined(__APPLE__)
|
||||||
|
/*
|
||||||
|
* Because we support the 'z' modifier, which made its appearance in C99,
|
||||||
|
* we can't use __attribute__ with pre C99 dialects.
|
||||||
|
*/
|
||||||
|
# if __STDC_VERSION__ >= 199901L
|
||||||
|
# undef ossl_bio__attr__
|
||||||
|
# define ossl_bio__attr__ __attribute__
|
||||||
|
# if __GNUC__*10 + __GNUC_MINOR__ >= 44
|
||||||
|
# define ossl_bio__printf__ __gnu_printf__
|
||||||
|
# else
|
||||||
|
# define ossl_bio__printf__ __printf__
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
int BIO_printf(BIO *bio, const char *format, ...)
|
||||||
|
ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3)));
|
||||||
|
int BIO_vprintf(BIO *bio, const char *format, va_list args)
|
||||||
|
ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0)));
|
||||||
|
int BIO_snprintf(char *buf, size_t n, const char *format, ...)
|
||||||
|
ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4)));
|
||||||
|
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
|
||||||
|
ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));
|
||||||
|
# undef ossl_bio__attr__
|
||||||
|
# undef ossl_bio__printf__
|
||||||
|
|
||||||
|
|
||||||
|
BIO_METHOD *BIO_meth_new(int type, const char *name);
|
||||||
|
void BIO_meth_free(BIO_METHOD *biom);
|
||||||
|
int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);
|
||||||
|
int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,
|
||||||
|
size_t *);
|
||||||
|
int BIO_meth_set_write(BIO_METHOD *biom,
|
||||||
|
int (*write) (BIO *, const char *, int));
|
||||||
|
int BIO_meth_set_write_ex(BIO_METHOD *biom,
|
||||||
|
int (*bwrite) (BIO *, const char *, size_t, size_t *));
|
||||||
|
int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);
|
||||||
|
int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *);
|
||||||
|
int BIO_meth_set_read(BIO_METHOD *biom,
|
||||||
|
int (*read) (BIO *, char *, int));
|
||||||
|
int BIO_meth_set_read_ex(BIO_METHOD *biom,
|
||||||
|
int (*bread) (BIO *, char *, size_t, size_t *));
|
||||||
|
int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);
|
||||||
|
int BIO_meth_set_puts(BIO_METHOD *biom,
|
||||||
|
int (*puts) (BIO *, const char *));
|
||||||
|
int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
|
||||||
|
int BIO_meth_set_gets(BIO_METHOD *biom,
|
||||||
|
int (*gets) (BIO *, char *, int));
|
||||||
|
long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);
|
||||||
|
int BIO_meth_set_ctrl(BIO_METHOD *biom,
|
||||||
|
long (*ctrl) (BIO *, int, long, void *));
|
||||||
|
int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);
|
||||||
|
int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));
|
||||||
|
int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);
|
||||||
|
int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));
|
||||||
|
long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))
|
||||||
|
(BIO *, int, BIO_info_cb *);
|
||||||
|
int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
|
||||||
|
long (*callback_ctrl) (BIO *, int,
|
||||||
|
BIO_info_cb *));
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
124
lib/OpenSSL/include/openssl/bioerr.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_BIOERR_H
|
||||||
|
# define HEADER_BIOERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_BIO_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BIO function codes.
|
||||||
|
*/
|
||||||
|
# define BIO_F_ACPT_STATE 100
|
||||||
|
# define BIO_F_ADDRINFO_WRAP 148
|
||||||
|
# define BIO_F_ADDR_STRINGS 134
|
||||||
|
# define BIO_F_BIO_ACCEPT 101
|
||||||
|
# define BIO_F_BIO_ACCEPT_EX 137
|
||||||
|
# define BIO_F_BIO_ACCEPT_NEW 152
|
||||||
|
# define BIO_F_BIO_ADDR_NEW 144
|
||||||
|
# define BIO_F_BIO_BIND 147
|
||||||
|
# define BIO_F_BIO_CALLBACK_CTRL 131
|
||||||
|
# define BIO_F_BIO_CONNECT 138
|
||||||
|
# define BIO_F_BIO_CONNECT_NEW 153
|
||||||
|
# define BIO_F_BIO_CTRL 103
|
||||||
|
# define BIO_F_BIO_GETS 104
|
||||||
|
# define BIO_F_BIO_GET_HOST_IP 106
|
||||||
|
# define BIO_F_BIO_GET_NEW_INDEX 102
|
||||||
|
# define BIO_F_BIO_GET_PORT 107
|
||||||
|
# define BIO_F_BIO_LISTEN 139
|
||||||
|
# define BIO_F_BIO_LOOKUP 135
|
||||||
|
# define BIO_F_BIO_LOOKUP_EX 143
|
||||||
|
# define BIO_F_BIO_MAKE_PAIR 121
|
||||||
|
# define BIO_F_BIO_METH_NEW 146
|
||||||
|
# define BIO_F_BIO_NEW 108
|
||||||
|
# define BIO_F_BIO_NEW_DGRAM_SCTP 145
|
||||||
|
# define BIO_F_BIO_NEW_FILE 109
|
||||||
|
# define BIO_F_BIO_NEW_MEM_BUF 126
|
||||||
|
# define BIO_F_BIO_NREAD 123
|
||||||
|
# define BIO_F_BIO_NREAD0 124
|
||||||
|
# define BIO_F_BIO_NWRITE 125
|
||||||
|
# define BIO_F_BIO_NWRITE0 122
|
||||||
|
# define BIO_F_BIO_PARSE_HOSTSERV 136
|
||||||
|
# define BIO_F_BIO_PUTS 110
|
||||||
|
# define BIO_F_BIO_READ 111
|
||||||
|
# define BIO_F_BIO_READ_EX 105
|
||||||
|
# define BIO_F_BIO_READ_INTERN 120
|
||||||
|
# define BIO_F_BIO_SOCKET 140
|
||||||
|
# define BIO_F_BIO_SOCKET_NBIO 142
|
||||||
|
# define BIO_F_BIO_SOCK_INFO 141
|
||||||
|
# define BIO_F_BIO_SOCK_INIT 112
|
||||||
|
# define BIO_F_BIO_WRITE 113
|
||||||
|
# define BIO_F_BIO_WRITE_EX 119
|
||||||
|
# define BIO_F_BIO_WRITE_INTERN 128
|
||||||
|
# define BIO_F_BUFFER_CTRL 114
|
||||||
|
# define BIO_F_CONN_CTRL 127
|
||||||
|
# define BIO_F_CONN_STATE 115
|
||||||
|
# define BIO_F_DGRAM_SCTP_NEW 149
|
||||||
|
# define BIO_F_DGRAM_SCTP_READ 132
|
||||||
|
# define BIO_F_DGRAM_SCTP_WRITE 133
|
||||||
|
# define BIO_F_DOAPR_OUTCH 150
|
||||||
|
# define BIO_F_FILE_CTRL 116
|
||||||
|
# define BIO_F_FILE_READ 130
|
||||||
|
# define BIO_F_LINEBUFFER_CTRL 129
|
||||||
|
# define BIO_F_LINEBUFFER_NEW 151
|
||||||
|
# define BIO_F_MEM_WRITE 117
|
||||||
|
# define BIO_F_NBIOF_NEW 154
|
||||||
|
# define BIO_F_SLG_WRITE 155
|
||||||
|
# define BIO_F_SSL_NEW 118
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BIO reason codes.
|
||||||
|
*/
|
||||||
|
# define BIO_R_ACCEPT_ERROR 100
|
||||||
|
# define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET 141
|
||||||
|
# define BIO_R_AMBIGUOUS_HOST_OR_SERVICE 129
|
||||||
|
# define BIO_R_BAD_FOPEN_MODE 101
|
||||||
|
# define BIO_R_BROKEN_PIPE 124
|
||||||
|
# define BIO_R_CONNECT_ERROR 103
|
||||||
|
# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107
|
||||||
|
# define BIO_R_GETSOCKNAME_ERROR 132
|
||||||
|
# define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS 133
|
||||||
|
# define BIO_R_GETTING_SOCKTYPE 134
|
||||||
|
# define BIO_R_INVALID_ARGUMENT 125
|
||||||
|
# define BIO_R_INVALID_SOCKET 135
|
||||||
|
# define BIO_R_IN_USE 123
|
||||||
|
# define BIO_R_LENGTH_TOO_LONG 102
|
||||||
|
# define BIO_R_LISTEN_V6_ONLY 136
|
||||||
|
# define BIO_R_LOOKUP_RETURNED_NOTHING 142
|
||||||
|
# define BIO_R_MALFORMED_HOST_OR_SERVICE 130
|
||||||
|
# define BIO_R_NBIO_CONNECT_ERROR 110
|
||||||
|
# define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED 143
|
||||||
|
# define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED 144
|
||||||
|
# define BIO_R_NO_PORT_DEFINED 113
|
||||||
|
# define BIO_R_NO_SUCH_FILE 128
|
||||||
|
# define BIO_R_NULL_PARAMETER 115
|
||||||
|
# define BIO_R_UNABLE_TO_BIND_SOCKET 117
|
||||||
|
# define BIO_R_UNABLE_TO_CREATE_SOCKET 118
|
||||||
|
# define BIO_R_UNABLE_TO_KEEPALIVE 137
|
||||||
|
# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119
|
||||||
|
# define BIO_R_UNABLE_TO_NODELAY 138
|
||||||
|
# define BIO_R_UNABLE_TO_REUSEADDR 139
|
||||||
|
# define BIO_R_UNAVAILABLE_IP_FAMILY 145
|
||||||
|
# define BIO_R_UNINITIALIZED 120
|
||||||
|
# define BIO_R_UNKNOWN_INFO_TYPE 140
|
||||||
|
# define BIO_R_UNSUPPORTED_IP_FAMILY 146
|
||||||
|
# define BIO_R_UNSUPPORTED_METHOD 121
|
||||||
|
# define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY 131
|
||||||
|
# define BIO_R_WRITE_TO_READ_ONLY_BIO 126
|
||||||
|
# define BIO_R_WSASTARTUP 122
|
||||||
|
|
||||||
|
#endif
|
61
lib/OpenSSL/include/openssl/blowfish.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_BLOWFISH_H
|
||||||
|
# define HEADER_BLOWFISH_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_BF
|
||||||
|
# include <openssl/e_os2.h>
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define BF_ENCRYPT 1
|
||||||
|
# define BF_DECRYPT 0
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
* ! BF_LONG has to be at least 32 bits wide. !
|
||||||
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
*/
|
||||||
|
# define BF_LONG unsigned int
|
||||||
|
|
||||||
|
# define BF_ROUNDS 16
|
||||||
|
# define BF_BLOCK 8
|
||||||
|
|
||||||
|
typedef struct bf_key_st {
|
||||||
|
BF_LONG P[BF_ROUNDS + 2];
|
||||||
|
BF_LONG S[4 * 256];
|
||||||
|
} BF_KEY;
|
||||||
|
|
||||||
|
void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
|
||||||
|
|
||||||
|
void BF_encrypt(BF_LONG *data, const BF_KEY *key);
|
||||||
|
void BF_decrypt(BF_LONG *data, const BF_KEY *key);
|
||||||
|
|
||||||
|
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const BF_KEY *key, int enc);
|
||||||
|
void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
|
||||||
|
const BF_KEY *schedule, unsigned char *ivec, int enc);
|
||||||
|
void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
long length, const BF_KEY *schedule,
|
||||||
|
unsigned char *ivec, int *num, int enc);
|
||||||
|
void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
long length, const BF_KEY *schedule,
|
||||||
|
unsigned char *ivec, int *num);
|
||||||
|
const char *BF_options(void);
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
539
lib/OpenSSL/include/openssl/bn.h
Normal file
@ -0,0 +1,539 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_BN_H
|
||||||
|
# define HEADER_BN_H
|
||||||
|
|
||||||
|
# include <openssl/e_os2.h>
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
# include <stdio.h>
|
||||||
|
# endif
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
# include <openssl/ossl_typ.h>
|
||||||
|
# include <openssl/crypto.h>
|
||||||
|
# include <openssl/bnerr.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 64-bit processor with LP64 ABI
|
||||||
|
*/
|
||||||
|
# ifdef SIXTY_FOUR_BIT_LONG
|
||||||
|
# define BN_ULONG unsigned long
|
||||||
|
# define BN_BYTES 8
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 64-bit processor other than LP64 ABI
|
||||||
|
*/
|
||||||
|
# ifdef SIXTY_FOUR_BIT
|
||||||
|
# define BN_ULONG unsigned long long
|
||||||
|
# define BN_BYTES 8
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef THIRTY_TWO_BIT
|
||||||
|
# define BN_ULONG unsigned int
|
||||||
|
# define BN_BYTES 4
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define BN_BITS2 (BN_BYTES * 8)
|
||||||
|
# define BN_BITS (BN_BITS2 * 2)
|
||||||
|
# define BN_TBIT ((BN_ULONG)1 << (BN_BITS2 - 1))
|
||||||
|
|
||||||
|
# define BN_FLG_MALLOCED 0x01
|
||||||
|
# define BN_FLG_STATIC_DATA 0x02
|
||||||
|
|
||||||
|
/*
|
||||||
|
* avoid leaking exponent information through timing,
|
||||||
|
* BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,
|
||||||
|
* BN_div() will call BN_div_no_branch,
|
||||||
|
* BN_mod_inverse() will call bn_mod_inverse_no_branch.
|
||||||
|
*/
|
||||||
|
# define BN_FLG_CONSTTIME 0x04
|
||||||
|
# define BN_FLG_SECURE 0x08
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT < 0x00908000L
|
||||||
|
/* deprecated name for the flag */
|
||||||
|
# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME
|
||||||
|
# define BN_FLG_FREE 0x8000 /* used for debugging */
|
||||||
|
# endif
|
||||||
|
|
||||||
|
void BN_set_flags(BIGNUM *b, int n);
|
||||||
|
int BN_get_flags(const BIGNUM *b, int n);
|
||||||
|
|
||||||
|
/* Values for |top| in BN_rand() */
|
||||||
|
#define BN_RAND_TOP_ANY -1
|
||||||
|
#define BN_RAND_TOP_ONE 0
|
||||||
|
#define BN_RAND_TOP_TWO 1
|
||||||
|
|
||||||
|
/* Values for |bottom| in BN_rand() */
|
||||||
|
#define BN_RAND_BOTTOM_ANY 0
|
||||||
|
#define BN_RAND_BOTTOM_ODD 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get a clone of a BIGNUM with changed flags, for *temporary* use only (the
|
||||||
|
* two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The
|
||||||
|
* value |dest| should be a newly allocated BIGNUM obtained via BN_new() that
|
||||||
|
* has not been otherwise initialised or used.
|
||||||
|
*/
|
||||||
|
void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags);
|
||||||
|
|
||||||
|
/* Wrapper function to make using BN_GENCB easier */
|
||||||
|
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
|
||||||
|
|
||||||
|
BN_GENCB *BN_GENCB_new(void);
|
||||||
|
void BN_GENCB_free(BN_GENCB *cb);
|
||||||
|
|
||||||
|
/* Populate a BN_GENCB structure with an "old"-style callback */
|
||||||
|
void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *),
|
||||||
|
void *cb_arg);
|
||||||
|
|
||||||
|
/* Populate a BN_GENCB structure with a "new"-style callback */
|
||||||
|
void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),
|
||||||
|
void *cb_arg);
|
||||||
|
|
||||||
|
void *BN_GENCB_get_arg(BN_GENCB *cb);
|
||||||
|
|
||||||
|
# define BN_prime_checks 0 /* default: select number of iterations based
|
||||||
|
* on the size of the number */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BN_prime_checks_for_size() returns the number of Miller-Rabin iterations
|
||||||
|
* that will be done for checking that a random number is probably prime. The
|
||||||
|
* error rate for accepting a composite number as prime depends on the size of
|
||||||
|
* the prime |b|. The error rates used are for calculating an RSA key with 2 primes,
|
||||||
|
* and so the level is what you would expect for a key of double the size of the
|
||||||
|
* prime.
|
||||||
|
*
|
||||||
|
* This table is generated using the algorithm of FIPS PUB 186-4
|
||||||
|
* Digital Signature Standard (DSS), section F.1, page 117.
|
||||||
|
* (https://dx.doi.org/10.6028/NIST.FIPS.186-4)
|
||||||
|
*
|
||||||
|
* The following magma script was used to generate the output:
|
||||||
|
* securitybits:=125;
|
||||||
|
* k:=1024;
|
||||||
|
* for t:=1 to 65 do
|
||||||
|
* for M:=3 to Floor(2*Sqrt(k-1)-1) do
|
||||||
|
* S:=0;
|
||||||
|
* // Sum over m
|
||||||
|
* for m:=3 to M do
|
||||||
|
* s:=0;
|
||||||
|
* // Sum over j
|
||||||
|
* for j:=2 to m do
|
||||||
|
* s+:=(RealField(32)!2)^-(j+(k-1)/j);
|
||||||
|
* end for;
|
||||||
|
* S+:=2^(m-(m-1)*t)*s;
|
||||||
|
* end for;
|
||||||
|
* A:=2^(k-2-M*t);
|
||||||
|
* B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S;
|
||||||
|
* pkt:=2.00743*Log(2)*k*2^-k*(A+B);
|
||||||
|
* seclevel:=Floor(-Log(2,pkt));
|
||||||
|
* if seclevel ge securitybits then
|
||||||
|
* printf "k: %5o, security: %o bits (t: %o, M: %o)\n",k,seclevel,t,M;
|
||||||
|
* break;
|
||||||
|
* end if;
|
||||||
|
* end for;
|
||||||
|
* if seclevel ge securitybits then break; end if;
|
||||||
|
* end for;
|
||||||
|
*
|
||||||
|
* It can be run online at:
|
||||||
|
* http://magma.maths.usyd.edu.au/calc
|
||||||
|
*
|
||||||
|
* And will output:
|
||||||
|
* k: 1024, security: 129 bits (t: 6, M: 23)
|
||||||
|
*
|
||||||
|
* k is the number of bits of the prime, securitybits is the level we want to
|
||||||
|
* reach.
|
||||||
|
*
|
||||||
|
* prime length | RSA key size | # MR tests | security level
|
||||||
|
* -------------+--------------|------------+---------------
|
||||||
|
* (b) >= 6394 | >= 12788 | 3 | 256 bit
|
||||||
|
* (b) >= 3747 | >= 7494 | 3 | 192 bit
|
||||||
|
* (b) >= 1345 | >= 2690 | 4 | 128 bit
|
||||||
|
* (b) >= 1080 | >= 2160 | 5 | 128 bit
|
||||||
|
* (b) >= 852 | >= 1704 | 5 | 112 bit
|
||||||
|
* (b) >= 476 | >= 952 | 5 | 80 bit
|
||||||
|
* (b) >= 400 | >= 800 | 6 | 80 bit
|
||||||
|
* (b) >= 347 | >= 694 | 7 | 80 bit
|
||||||
|
* (b) >= 308 | >= 616 | 8 | 80 bit
|
||||||
|
* (b) >= 55 | >= 110 | 27 | 64 bit
|
||||||
|
* (b) >= 6 | >= 12 | 34 | 64 bit
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define BN_prime_checks_for_size(b) ((b) >= 3747 ? 3 : \
|
||||||
|
(b) >= 1345 ? 4 : \
|
||||||
|
(b) >= 476 ? 5 : \
|
||||||
|
(b) >= 400 ? 6 : \
|
||||||
|
(b) >= 347 ? 7 : \
|
||||||
|
(b) >= 308 ? 8 : \
|
||||||
|
(b) >= 55 ? 27 : \
|
||||||
|
/* b >= 6 */ 34)
|
||||||
|
|
||||||
|
# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||||
|
|
||||||
|
int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);
|
||||||
|
int BN_is_zero(const BIGNUM *a);
|
||||||
|
int BN_is_one(const BIGNUM *a);
|
||||||
|
int BN_is_word(const BIGNUM *a, const BN_ULONG w);
|
||||||
|
int BN_is_odd(const BIGNUM *a);
|
||||||
|
|
||||||
|
# define BN_one(a) (BN_set_word((a),1))
|
||||||
|
|
||||||
|
void BN_zero_ex(BIGNUM *a);
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT >= 0x00908000L
|
||||||
|
# define BN_zero(a) BN_zero_ex(a)
|
||||||
|
# else
|
||||||
|
# define BN_zero(a) (BN_set_word((a),0))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
const BIGNUM *BN_value_one(void);
|
||||||
|
char *BN_options(void);
|
||||||
|
BN_CTX *BN_CTX_new(void);
|
||||||
|
BN_CTX *BN_CTX_secure_new(void);
|
||||||
|
void BN_CTX_free(BN_CTX *c);
|
||||||
|
void BN_CTX_start(BN_CTX *ctx);
|
||||||
|
BIGNUM *BN_CTX_get(BN_CTX *ctx);
|
||||||
|
void BN_CTX_end(BN_CTX *ctx);
|
||||||
|
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||||
|
int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||||
|
int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||||
|
int BN_priv_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||||
|
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||||
|
int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||||
|
int BN_num_bits(const BIGNUM *a);
|
||||||
|
int BN_num_bits_word(BN_ULONG l);
|
||||||
|
int BN_security_bits(int L, int N);
|
||||||
|
BIGNUM *BN_new(void);
|
||||||
|
BIGNUM *BN_secure_new(void);
|
||||||
|
void BN_clear_free(BIGNUM *a);
|
||||||
|
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
|
||||||
|
void BN_swap(BIGNUM *a, BIGNUM *b);
|
||||||
|
BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||||
|
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
|
||||||
|
int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||||
|
BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||||
|
int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||||
|
BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||||
|
int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
|
||||||
|
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||||
|
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||||
|
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||||
|
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||||
|
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||||
|
int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
|
||||||
|
/** BN_set_negative sets sign of a BIGNUM
|
||||||
|
* \param b pointer to the BIGNUM object
|
||||||
|
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
|
||||||
|
*/
|
||||||
|
void BN_set_negative(BIGNUM *b, int n);
|
||||||
|
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||||
|
* \param b pointer to the BIGNUM object
|
||||||
|
* \return 1 if a < 0 and 0 otherwise
|
||||||
|
*/
|
||||||
|
int BN_is_negative(const BIGNUM *b);
|
||||||
|
|
||||||
|
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
|
||||||
|
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||||
|
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const BIGNUM *m);
|
||||||
|
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const BIGNUM *m);
|
||||||
|
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||||
|
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||||
|
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
|
||||||
|
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
|
||||||
|
|
||||||
|
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
|
||||||
|
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||||
|
int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||||
|
int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||||
|
int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||||
|
int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||||
|
BN_ULONG BN_get_word(const BIGNUM *a);
|
||||||
|
|
||||||
|
int BN_cmp(const BIGNUM *a, const BIGNUM *b);
|
||||||
|
void BN_free(BIGNUM *a);
|
||||||
|
int BN_is_bit_set(const BIGNUM *a, int n);
|
||||||
|
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||||
|
int BN_lshift1(BIGNUM *r, const BIGNUM *a);
|
||||||
|
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
|
||||||
|
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||||
|
const BIGNUM *m, BN_CTX *ctx);
|
||||||
|
int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||||
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||||
|
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||||
|
const BIGNUM *m, BN_CTX *ctx,
|
||||||
|
BN_MONT_CTX *in_mont);
|
||||||
|
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
|
||||||
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||||
|
int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
|
||||||
|
const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,
|
||||||
|
BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||||
|
int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||||
|
const BIGNUM *m, BN_CTX *ctx);
|
||||||
|
|
||||||
|
int BN_mask_bits(BIGNUM *a, int n);
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
int BN_print_fp(FILE *fp, const BIGNUM *a);
|
||||||
|
# endif
|
||||||
|
int BN_print(BIO *bio, const BIGNUM *a);
|
||||||
|
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
|
||||||
|
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||||
|
int BN_rshift1(BIGNUM *r, const BIGNUM *a);
|
||||||
|
void BN_clear(BIGNUM *a);
|
||||||
|
BIGNUM *BN_dup(const BIGNUM *a);
|
||||||
|
int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
|
||||||
|
int BN_set_bit(BIGNUM *a, int n);
|
||||||
|
int BN_clear_bit(BIGNUM *a, int n);
|
||||||
|
char *BN_bn2hex(const BIGNUM *a);
|
||||||
|
char *BN_bn2dec(const BIGNUM *a);
|
||||||
|
int BN_hex2bn(BIGNUM **a, const char *str);
|
||||||
|
int BN_dec2bn(BIGNUM **a, const char *str);
|
||||||
|
int BN_asc2bn(BIGNUM **a, const char *str);
|
||||||
|
int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||||
|
int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns
|
||||||
|
* -2 for
|
||||||
|
* error */
|
||||||
|
BIGNUM *BN_mod_inverse(BIGNUM *ret,
|
||||||
|
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
|
||||||
|
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
|
||||||
|
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
|
||||||
|
|
||||||
|
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);
|
||||||
|
|
||||||
|
/* Deprecated versions */
|
||||||
|
DEPRECATEDIN_0_9_8(BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
|
||||||
|
const BIGNUM *add,
|
||||||
|
const BIGNUM *rem,
|
||||||
|
void (*callback) (int, int,
|
||||||
|
void *),
|
||||||
|
void *cb_arg))
|
||||||
|
DEPRECATEDIN_0_9_8(int
|
||||||
|
BN_is_prime(const BIGNUM *p, int nchecks,
|
||||||
|
void (*callback) (int, int, void *),
|
||||||
|
BN_CTX *ctx, void *cb_arg))
|
||||||
|
DEPRECATEDIN_0_9_8(int
|
||||||
|
BN_is_prime_fasttest(const BIGNUM *p, int nchecks,
|
||||||
|
void (*callback) (int, int, void *),
|
||||||
|
BN_CTX *ctx, void *cb_arg,
|
||||||
|
int do_trial_division))
|
||||||
|
|
||||||
|
/* Newer versions */
|
||||||
|
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
|
||||||
|
const BIGNUM *rem, BN_GENCB *cb);
|
||||||
|
int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);
|
||||||
|
int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,
|
||||||
|
int do_trial_division, BN_GENCB *cb);
|
||||||
|
|
||||||
|
int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
|
||||||
|
|
||||||
|
int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||||
|
const BIGNUM *Xp, const BIGNUM *Xp1,
|
||||||
|
const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,
|
||||||
|
BN_GENCB *cb);
|
||||||
|
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,
|
||||||
|
BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,
|
||||||
|
BN_CTX *ctx, BN_GENCB *cb);
|
||||||
|
|
||||||
|
BN_MONT_CTX *BN_MONT_CTX_new(void);
|
||||||
|
int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||||
|
int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||||
|
int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);
|
||||||
|
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
|
||||||
|
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock,
|
||||||
|
const BIGNUM *mod, BN_CTX *ctx);
|
||||||
|
|
||||||
|
/* BN_BLINDING flags */
|
||||||
|
# define BN_BLINDING_NO_UPDATE 0x00000001
|
||||||
|
# define BN_BLINDING_NO_RECREATE 0x00000002
|
||||||
|
|
||||||
|
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
|
||||||
|
void BN_BLINDING_free(BN_BLINDING *b);
|
||||||
|
int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);
|
||||||
|
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||||
|
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||||
|
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||||
|
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
|
||||||
|
BN_CTX *);
|
||||||
|
|
||||||
|
int BN_BLINDING_is_current_thread(BN_BLINDING *b);
|
||||||
|
void BN_BLINDING_set_current_thread(BN_BLINDING *b);
|
||||||
|
int BN_BLINDING_lock(BN_BLINDING *b);
|
||||||
|
int BN_BLINDING_unlock(BN_BLINDING *b);
|
||||||
|
|
||||||
|
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
|
||||||
|
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
|
||||||
|
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||||
|
const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
|
||||||
|
int (*bn_mod_exp) (BIGNUM *r,
|
||||||
|
const BIGNUM *a,
|
||||||
|
const BIGNUM *p,
|
||||||
|
const BIGNUM *m,
|
||||||
|
BN_CTX *ctx,
|
||||||
|
BN_MONT_CTX *m_ctx),
|
||||||
|
BN_MONT_CTX *m_ctx);
|
||||||
|
|
||||||
|
DEPRECATEDIN_0_9_8(void BN_set_params(int mul, int high, int low, int mont))
|
||||||
|
DEPRECATEDIN_0_9_8(int BN_get_params(int which)) /* 0, mul, 1 high, 2 low, 3
|
||||||
|
* mont */
|
||||||
|
|
||||||
|
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
||||||
|
void BN_RECP_CTX_free(BN_RECP_CTX *recp);
|
||||||
|
int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);
|
||||||
|
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
|
||||||
|
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||||
|
int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||||
|
const BIGNUM *m, BN_CTX *ctx);
|
||||||
|
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
|
||||||
|
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_EC2M
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions for arithmetic over binary polynomials represented by BIGNUMs.
|
||||||
|
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is
|
||||||
|
* ignored. Note that input arguments are not const so that their bit arrays
|
||||||
|
* can be expanded to the appropriate size if needed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* r = a + b
|
||||||
|
*/
|
||||||
|
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||||
|
# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
|
||||||
|
/*
|
||||||
|
* r=a mod p
|
||||||
|
*/
|
||||||
|
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);
|
||||||
|
/* r = (a * b) mod p */
|
||||||
|
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
/* r = (a * a) mod p */
|
||||||
|
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
/* r = (1 / b) mod p */
|
||||||
|
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
/* r = (a / b) mod p */
|
||||||
|
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
/* r = (a ^ b) mod p */
|
||||||
|
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
/* r = sqrt(a) mod p */
|
||||||
|
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
/* r^2 + r = a mod p */
|
||||||
|
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||||
|
BN_CTX *ctx);
|
||||||
|
# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
|
||||||
|
/*-
|
||||||
|
* Some functions allow for representation of the irreducible polynomials
|
||||||
|
* as an unsigned int[], say p. The irreducible f(t) is then of the form:
|
||||||
|
* t^p[0] + t^p[1] + ... + t^p[k]
|
||||||
|
* where m = p[0] > p[1] > ... > p[k] = 0.
|
||||||
|
*/
|
||||||
|
/* r = a mod p */
|
||||||
|
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
|
||||||
|
/* r = (a * b) mod p */
|
||||||
|
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const int p[], BN_CTX *ctx);
|
||||||
|
/* r = (a * a) mod p */
|
||||||
|
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
|
||||||
|
BN_CTX *ctx);
|
||||||
|
/* r = (1 / b) mod p */
|
||||||
|
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
|
||||||
|
BN_CTX *ctx);
|
||||||
|
/* r = (a / b) mod p */
|
||||||
|
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const int p[], BN_CTX *ctx);
|
||||||
|
/* r = (a ^ b) mod p */
|
||||||
|
int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||||
|
const int p[], BN_CTX *ctx);
|
||||||
|
/* r = sqrt(a) mod p */
|
||||||
|
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
|
||||||
|
const int p[], BN_CTX *ctx);
|
||||||
|
/* r^2 + r = a mod p */
|
||||||
|
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
|
||||||
|
const int p[], BN_CTX *ctx);
|
||||||
|
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
|
||||||
|
int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* faster mod functions for the 'NIST primes' 0 <= a < p^2
|
||||||
|
*/
|
||||||
|
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||||
|
|
||||||
|
const BIGNUM *BN_get0_nist_prime_192(void);
|
||||||
|
const BIGNUM *BN_get0_nist_prime_224(void);
|
||||||
|
const BIGNUM *BN_get0_nist_prime_256(void);
|
||||||
|
const BIGNUM *BN_get0_nist_prime_384(void);
|
||||||
|
const BIGNUM *BN_get0_nist_prime_521(void);
|
||||||
|
|
||||||
|
int (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a,
|
||||||
|
const BIGNUM *field, BN_CTX *ctx);
|
||||||
|
|
||||||
|
int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||||
|
const BIGNUM *priv, const unsigned char *message,
|
||||||
|
size_t message_len, BN_CTX *ctx);
|
||||||
|
|
||||||
|
/* Primes from RFC 2409 */
|
||||||
|
BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn);
|
||||||
|
BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn);
|
||||||
|
|
||||||
|
/* Primes from RFC 3526 */
|
||||||
|
BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn);
|
||||||
|
BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn);
|
||||||
|
BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn);
|
||||||
|
BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn);
|
||||||
|
BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn);
|
||||||
|
BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn);
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# define get_rfc2409_prime_768 BN_get_rfc2409_prime_768
|
||||||
|
# define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024
|
||||||
|
# define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536
|
||||||
|
# define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048
|
||||||
|
# define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072
|
||||||
|
# define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096
|
||||||
|
# define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144
|
||||||
|
# define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192
|
||||||
|
# endif
|
||||||
|
|
||||||
|
int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
101
lib/OpenSSL/include/openssl/bnerr.h
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_BNERR_H
|
||||||
|
# define HEADER_BNERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_BN_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BN function codes.
|
||||||
|
*/
|
||||||
|
# define BN_F_BNRAND 127
|
||||||
|
# define BN_F_BNRAND_RANGE 138
|
||||||
|
# define BN_F_BN_BLINDING_CONVERT_EX 100
|
||||||
|
# define BN_F_BN_BLINDING_CREATE_PARAM 128
|
||||||
|
# define BN_F_BN_BLINDING_INVERT_EX 101
|
||||||
|
# define BN_F_BN_BLINDING_NEW 102
|
||||||
|
# define BN_F_BN_BLINDING_UPDATE 103
|
||||||
|
# define BN_F_BN_BN2DEC 104
|
||||||
|
# define BN_F_BN_BN2HEX 105
|
||||||
|
# define BN_F_BN_COMPUTE_WNAF 142
|
||||||
|
# define BN_F_BN_CTX_GET 116
|
||||||
|
# define BN_F_BN_CTX_NEW 106
|
||||||
|
# define BN_F_BN_CTX_START 129
|
||||||
|
# define BN_F_BN_DIV 107
|
||||||
|
# define BN_F_BN_DIV_RECP 130
|
||||||
|
# define BN_F_BN_EXP 123
|
||||||
|
# define BN_F_BN_EXPAND_INTERNAL 120
|
||||||
|
# define BN_F_BN_GENCB_NEW 143
|
||||||
|
# define BN_F_BN_GENERATE_DSA_NONCE 140
|
||||||
|
# define BN_F_BN_GENERATE_PRIME_EX 141
|
||||||
|
# define BN_F_BN_GF2M_MOD 131
|
||||||
|
# define BN_F_BN_GF2M_MOD_EXP 132
|
||||||
|
# define BN_F_BN_GF2M_MOD_MUL 133
|
||||||
|
# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134
|
||||||
|
# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
|
||||||
|
# define BN_F_BN_GF2M_MOD_SQR 136
|
||||||
|
# define BN_F_BN_GF2M_MOD_SQRT 137
|
||||||
|
# define BN_F_BN_LSHIFT 145
|
||||||
|
# define BN_F_BN_MOD_EXP2_MONT 118
|
||||||
|
# define BN_F_BN_MOD_EXP_MONT 109
|
||||||
|
# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124
|
||||||
|
# define BN_F_BN_MOD_EXP_MONT_WORD 117
|
||||||
|
# define BN_F_BN_MOD_EXP_RECP 125
|
||||||
|
# define BN_F_BN_MOD_EXP_SIMPLE 126
|
||||||
|
# define BN_F_BN_MOD_INVERSE 110
|
||||||
|
# define BN_F_BN_MOD_INVERSE_NO_BRANCH 139
|
||||||
|
# define BN_F_BN_MOD_LSHIFT_QUICK 119
|
||||||
|
# define BN_F_BN_MOD_SQRT 121
|
||||||
|
# define BN_F_BN_MONT_CTX_NEW 149
|
||||||
|
# define BN_F_BN_MPI2BN 112
|
||||||
|
# define BN_F_BN_NEW 113
|
||||||
|
# define BN_F_BN_POOL_GET 147
|
||||||
|
# define BN_F_BN_RAND 114
|
||||||
|
# define BN_F_BN_RAND_RANGE 122
|
||||||
|
# define BN_F_BN_RECP_CTX_NEW 150
|
||||||
|
# define BN_F_BN_RSHIFT 146
|
||||||
|
# define BN_F_BN_SET_WORDS 144
|
||||||
|
# define BN_F_BN_STACK_PUSH 148
|
||||||
|
# define BN_F_BN_USUB 115
|
||||||
|
# define BN_F_OSSL_BN_RSA_DO_UNBLIND 151
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BN reason codes.
|
||||||
|
*/
|
||||||
|
# define BN_R_ARG2_LT_ARG3 100
|
||||||
|
# define BN_R_BAD_RECIPROCAL 101
|
||||||
|
# define BN_R_BIGNUM_TOO_LONG 114
|
||||||
|
# define BN_R_BITS_TOO_SMALL 118
|
||||||
|
# define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
||||||
|
# define BN_R_DIV_BY_ZERO 103
|
||||||
|
# define BN_R_ENCODING_ERROR 104
|
||||||
|
# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||||
|
# define BN_R_INPUT_NOT_REDUCED 110
|
||||||
|
# define BN_R_INVALID_LENGTH 106
|
||||||
|
# define BN_R_INVALID_RANGE 115
|
||||||
|
# define BN_R_INVALID_SHIFT 119
|
||||||
|
# define BN_R_NOT_A_SQUARE 111
|
||||||
|
# define BN_R_NOT_INITIALIZED 107
|
||||||
|
# define BN_R_NO_INVERSE 108
|
||||||
|
# define BN_R_NO_SOLUTION 116
|
||||||
|
# define BN_R_PRIVATE_KEY_TOO_LARGE 117
|
||||||
|
# define BN_R_P_IS_NOT_PRIME 112
|
||||||
|
# define BN_R_TOO_MANY_ITERATIONS 113
|
||||||
|
# define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
|
||||||
|
|
||||||
|
#endif
|
58
lib/OpenSSL/include/openssl/buffer.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_BUFFER_H
|
||||||
|
# define HEADER_BUFFER_H
|
||||||
|
|
||||||
|
# include <openssl/ossl_typ.h>
|
||||||
|
# ifndef HEADER_CRYPTO_H
|
||||||
|
# include <openssl/crypto.h>
|
||||||
|
# endif
|
||||||
|
# include <openssl/buffererr.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# include <stddef.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These names are outdated as of OpenSSL 1.1; a future release
|
||||||
|
* will move them to be deprecated.
|
||||||
|
*/
|
||||||
|
# define BUF_strdup(s) OPENSSL_strdup(s)
|
||||||
|
# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
|
||||||
|
# define BUF_memdup(data, size) OPENSSL_memdup(data, size)
|
||||||
|
# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size)
|
||||||
|
# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
|
||||||
|
# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
|
||||||
|
|
||||||
|
struct buf_mem_st {
|
||||||
|
size_t length; /* current number of bytes */
|
||||||
|
char *data;
|
||||||
|
size_t max; /* size of buffer */
|
||||||
|
unsigned long flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
# define BUF_MEM_FLAG_SECURE 0x01
|
||||||
|
|
||||||
|
BUF_MEM *BUF_MEM_new(void);
|
||||||
|
BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
|
||||||
|
void BUF_MEM_free(BUF_MEM *a);
|
||||||
|
size_t BUF_MEM_grow(BUF_MEM *str, size_t len);
|
||||||
|
size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
|
||||||
|
void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
34
lib/OpenSSL/include/openssl/buffererr.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_BUFERR_H
|
||||||
|
# define HEADER_BUFERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_BUF_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BUF function codes.
|
||||||
|
*/
|
||||||
|
# define BUF_F_BUF_MEM_GROW 100
|
||||||
|
# define BUF_F_BUF_MEM_GROW_CLEAN 105
|
||||||
|
# define BUF_F_BUF_MEM_NEW 101
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BUF reason codes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif
|
83
lib/OpenSSL/include/openssl/camellia.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CAMELLIA_H
|
||||||
|
# define HEADER_CAMELLIA_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_CAMELLIA
|
||||||
|
# include <stddef.h>
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# define CAMELLIA_ENCRYPT 1
|
||||||
|
# define CAMELLIA_DECRYPT 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Because array size can't be a const in C, the following two are macros.
|
||||||
|
* Both sizes are in bytes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This should be a hidden type, but EVP requires that the size be known */
|
||||||
|
|
||||||
|
# define CAMELLIA_BLOCK_SIZE 16
|
||||||
|
# define CAMELLIA_TABLE_BYTE_LEN 272
|
||||||
|
# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
|
||||||
|
|
||||||
|
typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
|
||||||
|
* with WORD */
|
||||||
|
|
||||||
|
struct camellia_key_st {
|
||||||
|
union {
|
||||||
|
double d; /* ensures 64-bit align */
|
||||||
|
KEY_TABLE_TYPE rd_key;
|
||||||
|
} u;
|
||||||
|
int grand_rounds;
|
||||||
|
};
|
||||||
|
typedef struct camellia_key_st CAMELLIA_KEY;
|
||||||
|
|
||||||
|
int Camellia_set_key(const unsigned char *userKey, const int bits,
|
||||||
|
CAMELLIA_KEY *key);
|
||||||
|
|
||||||
|
void Camellia_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const CAMELLIA_KEY *key);
|
||||||
|
void Camellia_decrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const CAMELLIA_KEY *key);
|
||||||
|
|
||||||
|
void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const CAMELLIA_KEY *key, const int enc);
|
||||||
|
void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const CAMELLIA_KEY *key,
|
||||||
|
unsigned char *ivec, const int enc);
|
||||||
|
void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const CAMELLIA_KEY *key,
|
||||||
|
unsigned char *ivec, int *num, const int enc);
|
||||||
|
void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const CAMELLIA_KEY *key,
|
||||||
|
unsigned char *ivec, int *num, const int enc);
|
||||||
|
void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const CAMELLIA_KEY *key,
|
||||||
|
unsigned char *ivec, int *num, const int enc);
|
||||||
|
void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const CAMELLIA_KEY *key,
|
||||||
|
unsigned char *ivec, int *num);
|
||||||
|
void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
size_t length, const CAMELLIA_KEY *key,
|
||||||
|
unsigned char ivec[CAMELLIA_BLOCK_SIZE],
|
||||||
|
unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
|
||||||
|
unsigned int *num);
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
53
lib/OpenSSL/include/openssl/cast.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CAST_H
|
||||||
|
# define HEADER_CAST_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_CAST
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define CAST_ENCRYPT 1
|
||||||
|
# define CAST_DECRYPT 0
|
||||||
|
|
||||||
|
# define CAST_LONG unsigned int
|
||||||
|
|
||||||
|
# define CAST_BLOCK 8
|
||||||
|
# define CAST_KEY_LENGTH 16
|
||||||
|
|
||||||
|
typedef struct cast_key_st {
|
||||||
|
CAST_LONG data[32];
|
||||||
|
int short_key; /* Use reduced rounds for short key */
|
||||||
|
} CAST_KEY;
|
||||||
|
|
||||||
|
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
|
||||||
|
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
const CAST_KEY *key, int enc);
|
||||||
|
void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||||
|
void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||||
|
void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
long length, const CAST_KEY *ks, unsigned char *iv,
|
||||||
|
int enc);
|
||||||
|
void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
long length, const CAST_KEY *schedule,
|
||||||
|
unsigned char *ivec, int *num, int enc);
|
||||||
|
void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||||
|
long length, const CAST_KEY *schedule,
|
||||||
|
unsigned char *ivec, int *num);
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
41
lib/OpenSSL/include/openssl/cmac.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CMAC_H
|
||||||
|
# define HEADER_CMAC_H
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_CMAC
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# include <openssl/evp.h>
|
||||||
|
|
||||||
|
/* Opaque */
|
||||||
|
typedef struct CMAC_CTX_st CMAC_CTX;
|
||||||
|
|
||||||
|
CMAC_CTX *CMAC_CTX_new(void);
|
||||||
|
void CMAC_CTX_cleanup(CMAC_CTX *ctx);
|
||||||
|
void CMAC_CTX_free(CMAC_CTX *ctx);
|
||||||
|
EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);
|
||||||
|
int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);
|
||||||
|
|
||||||
|
int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
|
||||||
|
const EVP_CIPHER *cipher, ENGINE *impl);
|
||||||
|
int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);
|
||||||
|
int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);
|
||||||
|
int CMAC_resume(CMAC_CTX *ctx);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# endif
|
||||||
|
#endif
|
339
lib/OpenSSL/include/openssl/cms.h
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CMS_H
|
||||||
|
# define HEADER_CMS_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_CMS
|
||||||
|
# include <openssl/x509.h>
|
||||||
|
# include <openssl/x509v3.h>
|
||||||
|
# include <openssl/cmserr.h>
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
typedef struct CMS_ContentInfo_st CMS_ContentInfo;
|
||||||
|
typedef struct CMS_SignerInfo_st CMS_SignerInfo;
|
||||||
|
typedef struct CMS_CertificateChoices CMS_CertificateChoices;
|
||||||
|
typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;
|
||||||
|
typedef struct CMS_RecipientInfo_st CMS_RecipientInfo;
|
||||||
|
typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;
|
||||||
|
typedef struct CMS_Receipt_st CMS_Receipt;
|
||||||
|
typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
|
||||||
|
typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(CMS_SignerInfo)
|
||||||
|
DEFINE_STACK_OF(CMS_RecipientEncryptedKey)
|
||||||
|
DEFINE_STACK_OF(CMS_RecipientInfo)
|
||||||
|
DEFINE_STACK_OF(CMS_RevocationInfoChoice)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
|
||||||
|
DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)
|
||||||
|
DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
|
||||||
|
|
||||||
|
# define CMS_SIGNERINFO_ISSUER_SERIAL 0
|
||||||
|
# define CMS_SIGNERINFO_KEYIDENTIFIER 1
|
||||||
|
|
||||||
|
# define CMS_RECIPINFO_NONE -1
|
||||||
|
# define CMS_RECIPINFO_TRANS 0
|
||||||
|
# define CMS_RECIPINFO_AGREE 1
|
||||||
|
# define CMS_RECIPINFO_KEK 2
|
||||||
|
# define CMS_RECIPINFO_PASS 3
|
||||||
|
# define CMS_RECIPINFO_OTHER 4
|
||||||
|
|
||||||
|
/* S/MIME related flags */
|
||||||
|
|
||||||
|
# define CMS_TEXT 0x1
|
||||||
|
# define CMS_NOCERTS 0x2
|
||||||
|
# define CMS_NO_CONTENT_VERIFY 0x4
|
||||||
|
# define CMS_NO_ATTR_VERIFY 0x8
|
||||||
|
# define CMS_NOSIGS \
|
||||||
|
(CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)
|
||||||
|
# define CMS_NOINTERN 0x10
|
||||||
|
# define CMS_NO_SIGNER_CERT_VERIFY 0x20
|
||||||
|
# define CMS_NOVERIFY 0x20
|
||||||
|
# define CMS_DETACHED 0x40
|
||||||
|
# define CMS_BINARY 0x80
|
||||||
|
# define CMS_NOATTR 0x100
|
||||||
|
# define CMS_NOSMIMECAP 0x200
|
||||||
|
# define CMS_NOOLDMIMETYPE 0x400
|
||||||
|
# define CMS_CRLFEOL 0x800
|
||||||
|
# define CMS_STREAM 0x1000
|
||||||
|
# define CMS_NOCRL 0x2000
|
||||||
|
# define CMS_PARTIAL 0x4000
|
||||||
|
# define CMS_REUSE_DIGEST 0x8000
|
||||||
|
# define CMS_USE_KEYID 0x10000
|
||||||
|
# define CMS_DEBUG_DECRYPT 0x20000
|
||||||
|
# define CMS_KEY_PARAM 0x40000
|
||||||
|
# define CMS_ASCIICRLF 0x80000
|
||||||
|
|
||||||
|
const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms);
|
||||||
|
|
||||||
|
BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);
|
||||||
|
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);
|
||||||
|
|
||||||
|
ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);
|
||||||
|
int CMS_is_detached(CMS_ContentInfo *cms);
|
||||||
|
int CMS_set_detached(CMS_ContentInfo *cms, int detached);
|
||||||
|
|
||||||
|
# ifdef HEADER_PEM_H
|
||||||
|
DECLARE_PEM_rw_const(CMS, CMS_ContentInfo)
|
||||||
|
# endif
|
||||||
|
int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);
|
||||||
|
CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);
|
||||||
|
int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);
|
||||||
|
|
||||||
|
BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);
|
||||||
|
int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);
|
||||||
|
int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,
|
||||||
|
int flags);
|
||||||
|
CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);
|
||||||
|
int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);
|
||||||
|
|
||||||
|
int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
|
CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,
|
||||||
|
STACK_OF(X509) *certs, BIO *data,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
|
CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
|
||||||
|
X509 *signcert, EVP_PKEY *pkey,
|
||||||
|
STACK_OF(X509) *certs, unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);
|
||||||
|
CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
||||||
|
unsigned int flags);
|
||||||
|
CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,
|
||||||
|
const unsigned char *key, size_t keylen,
|
||||||
|
BIO *dcont, BIO *out, unsigned int flags);
|
||||||
|
|
||||||
|
CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
|
||||||
|
const unsigned char *key,
|
||||||
|
size_t keylen, unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,
|
||||||
|
const unsigned char *key, size_t keylen);
|
||||||
|
|
||||||
|
int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
|
||||||
|
X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,
|
||||||
|
STACK_OF(X509) *certs,
|
||||||
|
X509_STORE *store, unsigned int flags);
|
||||||
|
|
||||||
|
STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
|
||||||
|
|
||||||
|
CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,
|
||||||
|
const EVP_CIPHER *cipher, unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
|
||||||
|
BIO *dcont, BIO *out, unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
|
||||||
|
int CMS_decrypt_set1_key(CMS_ContentInfo *cms,
|
||||||
|
unsigned char *key, size_t keylen,
|
||||||
|
const unsigned char *id, size_t idlen);
|
||||||
|
int CMS_decrypt_set1_password(CMS_ContentInfo *cms,
|
||||||
|
unsigned char *pass, ossl_ssize_t passlen);
|
||||||
|
|
||||||
|
STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);
|
||||||
|
int CMS_RecipientInfo_type(CMS_RecipientInfo *ri);
|
||||||
|
EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);
|
||||||
|
CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);
|
||||||
|
CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,
|
||||||
|
X509 *recip, unsigned int flags);
|
||||||
|
int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
|
||||||
|
int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);
|
||||||
|
int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,
|
||||||
|
EVP_PKEY **pk, X509 **recip,
|
||||||
|
X509_ALGOR **palg);
|
||||||
|
int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
|
||||||
|
ASN1_OCTET_STRING **keyid,
|
||||||
|
X509_NAME **issuer,
|
||||||
|
ASN1_INTEGER **sno);
|
||||||
|
|
||||||
|
CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,
|
||||||
|
unsigned char *key, size_t keylen,
|
||||||
|
unsigned char *id, size_t idlen,
|
||||||
|
ASN1_GENERALIZEDTIME *date,
|
||||||
|
ASN1_OBJECT *otherTypeId,
|
||||||
|
ASN1_TYPE *otherType);
|
||||||
|
|
||||||
|
int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,
|
||||||
|
X509_ALGOR **palg,
|
||||||
|
ASN1_OCTET_STRING **pid,
|
||||||
|
ASN1_GENERALIZEDTIME **pdate,
|
||||||
|
ASN1_OBJECT **potherid,
|
||||||
|
ASN1_TYPE **pothertype);
|
||||||
|
|
||||||
|
int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,
|
||||||
|
unsigned char *key, size_t keylen);
|
||||||
|
|
||||||
|
int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,
|
||||||
|
const unsigned char *id, size_t idlen);
|
||||||
|
|
||||||
|
int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,
|
||||||
|
unsigned char *pass,
|
||||||
|
ossl_ssize_t passlen);
|
||||||
|
|
||||||
|
CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
|
||||||
|
int iter, int wrap_nid,
|
||||||
|
int pbe_nid,
|
||||||
|
unsigned char *pass,
|
||||||
|
ossl_ssize_t passlen,
|
||||||
|
const EVP_CIPHER *kekciph);
|
||||||
|
|
||||||
|
int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
|
||||||
|
int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
|
||||||
|
|
||||||
|
int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
||||||
|
unsigned int flags);
|
||||||
|
CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);
|
||||||
|
|
||||||
|
int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);
|
||||||
|
const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);
|
||||||
|
|
||||||
|
CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);
|
||||||
|
int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
|
||||||
|
int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
|
||||||
|
STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);
|
||||||
|
|
||||||
|
CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);
|
||||||
|
int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
|
||||||
|
int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
|
||||||
|
STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);
|
||||||
|
|
||||||
|
int CMS_SignedData_init(CMS_ContentInfo *cms);
|
||||||
|
CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
|
||||||
|
X509 *signer, EVP_PKEY *pk, const EVP_MD *md,
|
||||||
|
unsigned int flags);
|
||||||
|
EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);
|
||||||
|
EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);
|
||||||
|
STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);
|
||||||
|
|
||||||
|
void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);
|
||||||
|
int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,
|
||||||
|
ASN1_OCTET_STRING **keyid,
|
||||||
|
X509_NAME **issuer, ASN1_INTEGER **sno);
|
||||||
|
int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);
|
||||||
|
int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
|
||||||
|
unsigned int flags);
|
||||||
|
void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,
|
||||||
|
X509 **signer, X509_ALGOR **pdig,
|
||||||
|
X509_ALGOR **psig);
|
||||||
|
ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);
|
||||||
|
int CMS_SignerInfo_sign(CMS_SignerInfo *si);
|
||||||
|
int CMS_SignerInfo_verify(CMS_SignerInfo *si);
|
||||||
|
int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);
|
||||||
|
|
||||||
|
int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);
|
||||||
|
int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,
|
||||||
|
int algnid, int keysize);
|
||||||
|
int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);
|
||||||
|
|
||||||
|
int CMS_signed_get_attr_count(const CMS_SignerInfo *si);
|
||||||
|
int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
|
||||||
|
int lastpos);
|
||||||
|
int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,
|
||||||
|
int lastpos);
|
||||||
|
X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);
|
||||||
|
X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);
|
||||||
|
int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
|
||||||
|
int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,
|
||||||
|
const ASN1_OBJECT *obj, int type,
|
||||||
|
const void *bytes, int len);
|
||||||
|
int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
|
||||||
|
int nid, int type,
|
||||||
|
const void *bytes, int len);
|
||||||
|
int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,
|
||||||
|
const char *attrname, int type,
|
||||||
|
const void *bytes, int len);
|
||||||
|
void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid,
|
||||||
|
int lastpos, int type);
|
||||||
|
|
||||||
|
int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);
|
||||||
|
int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
|
||||||
|
int lastpos);
|
||||||
|
int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,
|
||||||
|
const ASN1_OBJECT *obj, int lastpos);
|
||||||
|
X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);
|
||||||
|
X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);
|
||||||
|
int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
|
||||||
|
int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,
|
||||||
|
const ASN1_OBJECT *obj, int type,
|
||||||
|
const void *bytes, int len);
|
||||||
|
int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,
|
||||||
|
int nid, int type,
|
||||||
|
const void *bytes, int len);
|
||||||
|
int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,
|
||||||
|
const char *attrname, int type,
|
||||||
|
const void *bytes, int len);
|
||||||
|
void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
|
||||||
|
int lastpos, int type);
|
||||||
|
|
||||||
|
int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);
|
||||||
|
CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,
|
||||||
|
int allorfirst,
|
||||||
|
STACK_OF(GENERAL_NAMES)
|
||||||
|
*receiptList, STACK_OF(GENERAL_NAMES)
|
||||||
|
*receiptsTo);
|
||||||
|
int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);
|
||||||
|
void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,
|
||||||
|
ASN1_STRING **pcid,
|
||||||
|
int *pallorfirst,
|
||||||
|
STACK_OF(GENERAL_NAMES) **plist,
|
||||||
|
STACK_OF(GENERAL_NAMES) **prto);
|
||||||
|
int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,
|
||||||
|
X509_ALGOR **palg,
|
||||||
|
ASN1_OCTET_STRING **pukm);
|
||||||
|
STACK_OF(CMS_RecipientEncryptedKey)
|
||||||
|
*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);
|
||||||
|
|
||||||
|
int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,
|
||||||
|
X509_ALGOR **pubalg,
|
||||||
|
ASN1_BIT_STRING **pubkey,
|
||||||
|
ASN1_OCTET_STRING **keyid,
|
||||||
|
X509_NAME **issuer,
|
||||||
|
ASN1_INTEGER **sno);
|
||||||
|
|
||||||
|
int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);
|
||||||
|
|
||||||
|
int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,
|
||||||
|
ASN1_OCTET_STRING **keyid,
|
||||||
|
ASN1_GENERALIZEDTIME **tm,
|
||||||
|
CMS_OtherKeyAttribute **other,
|
||||||
|
X509_NAME **issuer, ASN1_INTEGER **sno);
|
||||||
|
int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,
|
||||||
|
X509 *cert);
|
||||||
|
int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);
|
||||||
|
EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);
|
||||||
|
int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,
|
||||||
|
CMS_RecipientInfo *ri,
|
||||||
|
CMS_RecipientEncryptedKey *rek);
|
||||||
|
|
||||||
|
int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,
|
||||||
|
ASN1_OCTET_STRING *ukm, int keylen);
|
||||||
|
|
||||||
|
/* Backward compatibility for spelling errors. */
|
||||||
|
# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM
|
||||||
|
# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \
|
||||||
|
CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
203
lib/OpenSSL/include/openssl/cmserr.h
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CMSERR_H
|
||||||
|
# define HEADER_CMSERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_CMS
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_CMS_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CMS function codes.
|
||||||
|
*/
|
||||||
|
# define CMS_F_CHECK_CONTENT 99
|
||||||
|
# define CMS_F_CMS_ADD0_CERT 164
|
||||||
|
# define CMS_F_CMS_ADD0_RECIPIENT_KEY 100
|
||||||
|
# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 165
|
||||||
|
# define CMS_F_CMS_ADD1_RECEIPTREQUEST 158
|
||||||
|
# define CMS_F_CMS_ADD1_RECIPIENT_CERT 101
|
||||||
|
# define CMS_F_CMS_ADD1_SIGNER 102
|
||||||
|
# define CMS_F_CMS_ADD1_SIGNINGTIME 103
|
||||||
|
# define CMS_F_CMS_COMPRESS 104
|
||||||
|
# define CMS_F_CMS_COMPRESSEDDATA_CREATE 105
|
||||||
|
# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 106
|
||||||
|
# define CMS_F_CMS_COPY_CONTENT 107
|
||||||
|
# define CMS_F_CMS_COPY_MESSAGEDIGEST 108
|
||||||
|
# define CMS_F_CMS_DATA 109
|
||||||
|
# define CMS_F_CMS_DATAFINAL 110
|
||||||
|
# define CMS_F_CMS_DATAINIT 111
|
||||||
|
# define CMS_F_CMS_DECRYPT 112
|
||||||
|
# define CMS_F_CMS_DECRYPT_SET1_KEY 113
|
||||||
|
# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 166
|
||||||
|
# define CMS_F_CMS_DECRYPT_SET1_PKEY 114
|
||||||
|
# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 115
|
||||||
|
# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 116
|
||||||
|
# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 117
|
||||||
|
# define CMS_F_CMS_DIGEST_VERIFY 118
|
||||||
|
# define CMS_F_CMS_ENCODE_RECEIPT 161
|
||||||
|
# define CMS_F_CMS_ENCRYPT 119
|
||||||
|
# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT 179
|
||||||
|
# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 120
|
||||||
|
# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 121
|
||||||
|
# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 122
|
||||||
|
# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 123
|
||||||
|
# define CMS_F_CMS_ENVELOPEDDATA_CREATE 124
|
||||||
|
# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 125
|
||||||
|
# define CMS_F_CMS_ENVELOPED_DATA_INIT 126
|
||||||
|
# define CMS_F_CMS_ENV_ASN1_CTRL 171
|
||||||
|
# define CMS_F_CMS_FINAL 127
|
||||||
|
# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 128
|
||||||
|
# define CMS_F_CMS_GET0_CONTENT 129
|
||||||
|
# define CMS_F_CMS_GET0_ECONTENT_TYPE 130
|
||||||
|
# define CMS_F_CMS_GET0_ENVELOPED 131
|
||||||
|
# define CMS_F_CMS_GET0_REVOCATION_CHOICES 132
|
||||||
|
# define CMS_F_CMS_GET0_SIGNED 133
|
||||||
|
# define CMS_F_CMS_MSGSIGDIGEST_ADD1 162
|
||||||
|
# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 159
|
||||||
|
# define CMS_F_CMS_RECEIPT_VERIFY 160
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 134
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 169
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 178
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 175
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 173
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 172
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 174
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 135
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 136
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 137
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 138
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 139
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 140
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 141
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 142
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 143
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 167
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 144
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 168
|
||||||
|
# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 145
|
||||||
|
# define CMS_F_CMS_SD_ASN1_CTRL 170
|
||||||
|
# define CMS_F_CMS_SET1_IAS 176
|
||||||
|
# define CMS_F_CMS_SET1_KEYID 177
|
||||||
|
# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 146
|
||||||
|
# define CMS_F_CMS_SET_DETACHED 147
|
||||||
|
# define CMS_F_CMS_SIGN 148
|
||||||
|
# define CMS_F_CMS_SIGNED_DATA_INIT 149
|
||||||
|
# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 150
|
||||||
|
# define CMS_F_CMS_SIGNERINFO_SIGN 151
|
||||||
|
# define CMS_F_CMS_SIGNERINFO_VERIFY 152
|
||||||
|
# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 153
|
||||||
|
# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 154
|
||||||
|
# define CMS_F_CMS_SIGN_RECEIPT 163
|
||||||
|
# define CMS_F_CMS_SI_CHECK_ATTRIBUTES 183
|
||||||
|
# define CMS_F_CMS_STREAM 155
|
||||||
|
# define CMS_F_CMS_UNCOMPRESS 156
|
||||||
|
# define CMS_F_CMS_VERIFY 157
|
||||||
|
# define CMS_F_KEK_UNWRAP_KEY 180
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CMS reason codes.
|
||||||
|
*/
|
||||||
|
# define CMS_R_ADD_SIGNER_ERROR 99
|
||||||
|
# define CMS_R_ATTRIBUTE_ERROR 161
|
||||||
|
# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175
|
||||||
|
# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160
|
||||||
|
# define CMS_R_CERTIFICATE_VERIFY_ERROR 100
|
||||||
|
# define CMS_R_CIPHER_INITIALISATION_ERROR 101
|
||||||
|
# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102
|
||||||
|
# define CMS_R_CMS_DATAFINAL_ERROR 103
|
||||||
|
# define CMS_R_CMS_LIB 104
|
||||||
|
# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170
|
||||||
|
# define CMS_R_CONTENT_NOT_FOUND 105
|
||||||
|
# define CMS_R_CONTENT_TYPE_MISMATCH 171
|
||||||
|
# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106
|
||||||
|
# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107
|
||||||
|
# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108
|
||||||
|
# define CMS_R_CONTENT_VERIFY_ERROR 109
|
||||||
|
# define CMS_R_CTRL_ERROR 110
|
||||||
|
# define CMS_R_CTRL_FAILURE 111
|
||||||
|
# define CMS_R_DECRYPT_ERROR 112
|
||||||
|
# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113
|
||||||
|
# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114
|
||||||
|
# define CMS_R_ERROR_SETTING_KEY 115
|
||||||
|
# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116
|
||||||
|
# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117
|
||||||
|
# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176
|
||||||
|
# define CMS_R_INVALID_KEY_LENGTH 118
|
||||||
|
# define CMS_R_MD_BIO_INIT_ERROR 119
|
||||||
|
# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120
|
||||||
|
# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121
|
||||||
|
# define CMS_R_MSGSIGDIGEST_ERROR 172
|
||||||
|
# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162
|
||||||
|
# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163
|
||||||
|
# define CMS_R_NEED_ONE_SIGNER 164
|
||||||
|
# define CMS_R_NOT_A_SIGNED_RECEIPT 165
|
||||||
|
# define CMS_R_NOT_ENCRYPTED_DATA 122
|
||||||
|
# define CMS_R_NOT_KEK 123
|
||||||
|
# define CMS_R_NOT_KEY_AGREEMENT 181
|
||||||
|
# define CMS_R_NOT_KEY_TRANSPORT 124
|
||||||
|
# define CMS_R_NOT_PWRI 177
|
||||||
|
# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125
|
||||||
|
# define CMS_R_NO_CIPHER 126
|
||||||
|
# define CMS_R_NO_CONTENT 127
|
||||||
|
# define CMS_R_NO_CONTENT_TYPE 173
|
||||||
|
# define CMS_R_NO_DEFAULT_DIGEST 128
|
||||||
|
# define CMS_R_NO_DIGEST_SET 129
|
||||||
|
# define CMS_R_NO_KEY 130
|
||||||
|
# define CMS_R_NO_KEY_OR_CERT 174
|
||||||
|
# define CMS_R_NO_MATCHING_DIGEST 131
|
||||||
|
# define CMS_R_NO_MATCHING_RECIPIENT 132
|
||||||
|
# define CMS_R_NO_MATCHING_SIGNATURE 166
|
||||||
|
# define CMS_R_NO_MSGSIGDIGEST 167
|
||||||
|
# define CMS_R_NO_PASSWORD 178
|
||||||
|
# define CMS_R_NO_PRIVATE_KEY 133
|
||||||
|
# define CMS_R_NO_PUBLIC_KEY 134
|
||||||
|
# define CMS_R_NO_RECEIPT_REQUEST 168
|
||||||
|
# define CMS_R_NO_SIGNERS 135
|
||||||
|
# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136
|
||||||
|
# define CMS_R_RECEIPT_DECODE_ERROR 169
|
||||||
|
# define CMS_R_RECIPIENT_ERROR 137
|
||||||
|
# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138
|
||||||
|
# define CMS_R_SIGNFINAL_ERROR 139
|
||||||
|
# define CMS_R_SMIME_TEXT_ERROR 140
|
||||||
|
# define CMS_R_STORE_INIT_ERROR 141
|
||||||
|
# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142
|
||||||
|
# define CMS_R_TYPE_NOT_DATA 143
|
||||||
|
# define CMS_R_TYPE_NOT_DIGESTED_DATA 144
|
||||||
|
# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145
|
||||||
|
# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146
|
||||||
|
# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147
|
||||||
|
# define CMS_R_UNKNOWN_CIPHER 148
|
||||||
|
# define CMS_R_UNKNOWN_DIGEST_ALGORITHM 149
|
||||||
|
# define CMS_R_UNKNOWN_ID 150
|
||||||
|
# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151
|
||||||
|
# define CMS_R_UNSUPPORTED_CONTENT_ENCRYPTION_ALGORITHM 194
|
||||||
|
# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152
|
||||||
|
# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153
|
||||||
|
# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179
|
||||||
|
# define CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE 155
|
||||||
|
# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154
|
||||||
|
# define CMS_R_UNSUPPORTED_TYPE 156
|
||||||
|
# define CMS_R_UNWRAP_ERROR 157
|
||||||
|
# define CMS_R_UNWRAP_FAILURE 180
|
||||||
|
# define CMS_R_VERIFICATION_FAILURE 158
|
||||||
|
# define CMS_R_WRAP_ERROR 159
|
||||||
|
|
||||||
|
# endif
|
||||||
|
#endif
|
53
lib/OpenSSL/include/openssl/comp.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_COMP_H
|
||||||
|
# define HEADER_COMP_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_COMP
|
||||||
|
# include <openssl/crypto.h>
|
||||||
|
# include <openssl/comperr.h>
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
|
||||||
|
const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx);
|
||||||
|
int COMP_CTX_get_type(const COMP_CTX* comp);
|
||||||
|
int COMP_get_type(const COMP_METHOD *meth);
|
||||||
|
const char *COMP_get_name(const COMP_METHOD *meth);
|
||||||
|
void COMP_CTX_free(COMP_CTX *ctx);
|
||||||
|
|
||||||
|
int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||||
|
unsigned char *in, int ilen);
|
||||||
|
int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||||
|
unsigned char *in, int ilen);
|
||||||
|
|
||||||
|
COMP_METHOD *COMP_zlib(void);
|
||||||
|
|
||||||
|
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
#define COMP_zlib_cleanup() while(0) continue
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# ifdef HEADER_BIO_H
|
||||||
|
# ifdef ZLIB
|
||||||
|
const BIO_METHOD *BIO_f_zlib(void);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
44
lib/OpenSSL/include/openssl/comperr.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_COMPERR_H
|
||||||
|
# define HEADER_COMPERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_COMP
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_COMP_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COMP function codes.
|
||||||
|
*/
|
||||||
|
# define COMP_F_BIO_ZLIB_FLUSH 99
|
||||||
|
# define COMP_F_BIO_ZLIB_NEW 100
|
||||||
|
# define COMP_F_BIO_ZLIB_READ 101
|
||||||
|
# define COMP_F_BIO_ZLIB_WRITE 102
|
||||||
|
# define COMP_F_COMP_CTX_NEW 103
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COMP reason codes.
|
||||||
|
*/
|
||||||
|
# define COMP_R_ZLIB_DEFLATE_ERROR 99
|
||||||
|
# define COMP_R_ZLIB_INFLATE_ERROR 100
|
||||||
|
# define COMP_R_ZLIB_NOT_SUPPORTED 101
|
||||||
|
|
||||||
|
# endif
|
||||||
|
#endif
|
168
lib/OpenSSL/include/openssl/conf.h
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CONF_H
|
||||||
|
# define HEADER_CONF_H
|
||||||
|
|
||||||
|
# include <openssl/bio.h>
|
||||||
|
# include <openssl/lhash.h>
|
||||||
|
# include <openssl/safestack.h>
|
||||||
|
# include <openssl/e_os2.h>
|
||||||
|
# include <openssl/ossl_typ.h>
|
||||||
|
# include <openssl/conferr.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *section;
|
||||||
|
char *name;
|
||||||
|
char *value;
|
||||||
|
} CONF_VALUE;
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(CONF_VALUE)
|
||||||
|
DEFINE_LHASH_OF(CONF_VALUE);
|
||||||
|
|
||||||
|
struct conf_st;
|
||||||
|
struct conf_method_st;
|
||||||
|
typedef struct conf_method_st CONF_METHOD;
|
||||||
|
|
||||||
|
struct conf_method_st {
|
||||||
|
const char *name;
|
||||||
|
CONF *(*create) (CONF_METHOD *meth);
|
||||||
|
int (*init) (CONF *conf);
|
||||||
|
int (*destroy) (CONF *conf);
|
||||||
|
int (*destroy_data) (CONF *conf);
|
||||||
|
int (*load_bio) (CONF *conf, BIO *bp, long *eline);
|
||||||
|
int (*dump) (const CONF *conf, BIO *bp);
|
||||||
|
int (*is_number) (const CONF *conf, char c);
|
||||||
|
int (*to_int) (const CONF *conf, char c);
|
||||||
|
int (*load) (CONF *conf, const char *name, long *eline);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Module definitions */
|
||||||
|
|
||||||
|
typedef struct conf_imodule_st CONF_IMODULE;
|
||||||
|
typedef struct conf_module_st CONF_MODULE;
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(CONF_MODULE)
|
||||||
|
DEFINE_STACK_OF(CONF_IMODULE)
|
||||||
|
|
||||||
|
/* DSO module function typedefs */
|
||||||
|
typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);
|
||||||
|
typedef void conf_finish_func (CONF_IMODULE *md);
|
||||||
|
|
||||||
|
# define CONF_MFLAGS_IGNORE_ERRORS 0x1
|
||||||
|
# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2
|
||||||
|
# define CONF_MFLAGS_SILENT 0x4
|
||||||
|
# define CONF_MFLAGS_NO_DSO 0x8
|
||||||
|
# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
|
||||||
|
# define CONF_MFLAGS_DEFAULT_SECTION 0x20
|
||||||
|
|
||||||
|
int CONF_set_default_method(CONF_METHOD *meth);
|
||||||
|
void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
|
||||||
|
LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
|
||||||
|
long *eline);
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
|
||||||
|
long *eline);
|
||||||
|
# endif
|
||||||
|
LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,
|
||||||
|
long *eline);
|
||||||
|
STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
|
||||||
|
const char *section);
|
||||||
|
char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
|
||||||
|
const char *name);
|
||||||
|
long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
|
||||||
|
const char *name);
|
||||||
|
void CONF_free(LHASH_OF(CONF_VALUE) *conf);
|
||||||
|
#ifndef OPENSSL_NO_STDIO
|
||||||
|
int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
|
||||||
|
#endif
|
||||||
|
int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
|
||||||
|
|
||||||
|
DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))
|
||||||
|
|
||||||
|
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# define OPENSSL_no_config() \
|
||||||
|
OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* New conf code. The semantics are different from the functions above. If
|
||||||
|
* that wasn't the case, the above functions would have been replaced
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct conf_st {
|
||||||
|
CONF_METHOD *meth;
|
||||||
|
void *meth_data;
|
||||||
|
LHASH_OF(CONF_VALUE) *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
CONF *NCONF_new(CONF_METHOD *meth);
|
||||||
|
CONF_METHOD *NCONF_default(void);
|
||||||
|
CONF_METHOD *NCONF_WIN32(void);
|
||||||
|
void NCONF_free(CONF *conf);
|
||||||
|
void NCONF_free_data(CONF *conf);
|
||||||
|
|
||||||
|
int NCONF_load(CONF *conf, const char *file, long *eline);
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
|
||||||
|
# endif
|
||||||
|
int NCONF_load_bio(CONF *conf, BIO *bp, long *eline);
|
||||||
|
STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
|
||||||
|
const char *section);
|
||||||
|
char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
|
||||||
|
int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
|
||||||
|
long *result);
|
||||||
|
#ifndef OPENSSL_NO_STDIO
|
||||||
|
int NCONF_dump_fp(const CONF *conf, FILE *out);
|
||||||
|
#endif
|
||||||
|
int NCONF_dump_bio(const CONF *conf, BIO *out);
|
||||||
|
|
||||||
|
#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
|
||||||
|
|
||||||
|
/* Module functions */
|
||||||
|
|
||||||
|
int CONF_modules_load(const CONF *cnf, const char *appname,
|
||||||
|
unsigned long flags);
|
||||||
|
int CONF_modules_load_file(const char *filename, const char *appname,
|
||||||
|
unsigned long flags);
|
||||||
|
void CONF_modules_unload(int all);
|
||||||
|
void CONF_modules_finish(void);
|
||||||
|
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# define CONF_modules_free() while(0) continue
|
||||||
|
#endif
|
||||||
|
int CONF_module_add(const char *name, conf_init_func *ifunc,
|
||||||
|
conf_finish_func *ffunc);
|
||||||
|
|
||||||
|
const char *CONF_imodule_get_name(const CONF_IMODULE *md);
|
||||||
|
const char *CONF_imodule_get_value(const CONF_IMODULE *md);
|
||||||
|
void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
|
||||||
|
void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
|
||||||
|
CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
|
||||||
|
unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
|
||||||
|
void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
|
||||||
|
void *CONF_module_get_usr_data(CONF_MODULE *pmod);
|
||||||
|
void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
|
||||||
|
|
||||||
|
char *CONF_get1_default_config_file(void);
|
||||||
|
|
||||||
|
int CONF_parse_list(const char *list, int sep, int nospc,
|
||||||
|
int (*list_cb) (const char *elem, int len, void *usr),
|
||||||
|
void *arg);
|
||||||
|
|
||||||
|
void OPENSSL_load_builtin_modules(void);
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
40
lib/OpenSSL/include/openssl/conf_api.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CONF_API_H
|
||||||
|
# define HEADER_CONF_API_H
|
||||||
|
|
||||||
|
# include <openssl/lhash.h>
|
||||||
|
# include <openssl/conf.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Up until OpenSSL 0.9.5a, this was new_section */
|
||||||
|
CONF_VALUE *_CONF_new_section(CONF *conf, const char *section);
|
||||||
|
/* Up until OpenSSL 0.9.5a, this was get_section */
|
||||||
|
CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);
|
||||||
|
/* Up until OpenSSL 0.9.5a, this was CONF_get_section */
|
||||||
|
STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,
|
||||||
|
const char *section);
|
||||||
|
|
||||||
|
int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);
|
||||||
|
char *_CONF_get_string(const CONF *conf, const char *section,
|
||||||
|
const char *name);
|
||||||
|
long _CONF_get_number(const CONF *conf, const char *section,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
int _CONF_new_data(CONF *conf);
|
||||||
|
void _CONF_free_data(CONF *conf);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
76
lib/OpenSSL/include/openssl/conferr.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CONFERR_H
|
||||||
|
# define HEADER_CONFERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_CONF_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CONF function codes.
|
||||||
|
*/
|
||||||
|
# define CONF_F_CONF_DUMP_FP 104
|
||||||
|
# define CONF_F_CONF_LOAD 100
|
||||||
|
# define CONF_F_CONF_LOAD_FP 103
|
||||||
|
# define CONF_F_CONF_PARSE_LIST 119
|
||||||
|
# define CONF_F_DEF_LOAD 120
|
||||||
|
# define CONF_F_DEF_LOAD_BIO 121
|
||||||
|
# define CONF_F_GET_NEXT_FILE 107
|
||||||
|
# define CONF_F_MODULE_ADD 122
|
||||||
|
# define CONF_F_MODULE_INIT 115
|
||||||
|
# define CONF_F_MODULE_LOAD_DSO 117
|
||||||
|
# define CONF_F_MODULE_RUN 118
|
||||||
|
# define CONF_F_NCONF_DUMP_BIO 105
|
||||||
|
# define CONF_F_NCONF_DUMP_FP 106
|
||||||
|
# define CONF_F_NCONF_GET_NUMBER_E 112
|
||||||
|
# define CONF_F_NCONF_GET_SECTION 108
|
||||||
|
# define CONF_F_NCONF_GET_STRING 109
|
||||||
|
# define CONF_F_NCONF_LOAD 113
|
||||||
|
# define CONF_F_NCONF_LOAD_BIO 110
|
||||||
|
# define CONF_F_NCONF_LOAD_FP 114
|
||||||
|
# define CONF_F_NCONF_NEW 111
|
||||||
|
# define CONF_F_PROCESS_INCLUDE 116
|
||||||
|
# define CONF_F_SSL_MODULE_INIT 123
|
||||||
|
# define CONF_F_STR_COPY 101
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CONF reason codes.
|
||||||
|
*/
|
||||||
|
# define CONF_R_ERROR_LOADING_DSO 110
|
||||||
|
# define CONF_R_LIST_CANNOT_BE_NULL 115
|
||||||
|
# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
|
||||||
|
# define CONF_R_MISSING_EQUAL_SIGN 101
|
||||||
|
# define CONF_R_MISSING_INIT_FUNCTION 112
|
||||||
|
# define CONF_R_MODULE_INITIALIZATION_ERROR 109
|
||||||
|
# define CONF_R_NO_CLOSE_BRACE 102
|
||||||
|
# define CONF_R_NO_CONF 105
|
||||||
|
# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106
|
||||||
|
# define CONF_R_NO_SECTION 107
|
||||||
|
# define CONF_R_NO_SUCH_FILE 114
|
||||||
|
# define CONF_R_NO_VALUE 108
|
||||||
|
# define CONF_R_NUMBER_TOO_LARGE 121
|
||||||
|
# define CONF_R_RECURSIVE_DIRECTORY_INCLUDE 111
|
||||||
|
# define CONF_R_SSL_COMMAND_SECTION_EMPTY 117
|
||||||
|
# define CONF_R_SSL_COMMAND_SECTION_NOT_FOUND 118
|
||||||
|
# define CONF_R_SSL_SECTION_EMPTY 119
|
||||||
|
# define CONF_R_SSL_SECTION_NOT_FOUND 120
|
||||||
|
# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
|
||||||
|
# define CONF_R_UNKNOWN_MODULE_NAME 113
|
||||||
|
# define CONF_R_VARIABLE_EXPANSION_TOO_LONG 116
|
||||||
|
# define CONF_R_VARIABLE_HAS_NO_VALUE 104
|
||||||
|
|
||||||
|
#endif
|
445
lib/OpenSSL/include/openssl/crypto.h
Normal file
@ -0,0 +1,445 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CRYPTO_H
|
||||||
|
# define HEADER_CRYPTO_H
|
||||||
|
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <time.h>
|
||||||
|
|
||||||
|
# include <openssl/e_os2.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
# include <stdio.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# include <openssl/safestack.h>
|
||||||
|
# include <openssl/opensslv.h>
|
||||||
|
# include <openssl/ossl_typ.h>
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
# include <openssl/cryptoerr.h>
|
||||||
|
|
||||||
|
# ifdef CHARSET_EBCDIC
|
||||||
|
# include <openssl/ebcdic.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Resolve problems on some operating systems with symbol names that clash
|
||||||
|
* one way or another
|
||||||
|
*/
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# include <openssl/opensslv.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# define SSLeay OpenSSL_version_num
|
||||||
|
# define SSLeay_version OpenSSL_version
|
||||||
|
# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
|
||||||
|
# define SSLEAY_VERSION OPENSSL_VERSION
|
||||||
|
# define SSLEAY_CFLAGS OPENSSL_CFLAGS
|
||||||
|
# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON
|
||||||
|
# define SSLEAY_PLATFORM OPENSSL_PLATFORM
|
||||||
|
# define SSLEAY_DIR OPENSSL_DIR
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Old type for allocating dynamic locks. No longer used. Use the new thread
|
||||||
|
* API instead.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int dummy;
|
||||||
|
} CRYPTO_dynlock;
|
||||||
|
|
||||||
|
# endif /* OPENSSL_API_COMPAT */
|
||||||
|
|
||||||
|
typedef void CRYPTO_RWLOCK;
|
||||||
|
|
||||||
|
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void);
|
||||||
|
int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock);
|
||||||
|
int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock);
|
||||||
|
int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock);
|
||||||
|
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock);
|
||||||
|
|
||||||
|
int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following can be used to detect memory leaks in the library. If
|
||||||
|
* used, it turns on malloc checking
|
||||||
|
*/
|
||||||
|
# define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */
|
||||||
|
# define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */
|
||||||
|
# define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */
|
||||||
|
# define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */
|
||||||
|
|
||||||
|
struct crypto_ex_data_st {
|
||||||
|
STACK_OF(void) *sk;
|
||||||
|
};
|
||||||
|
DEFINE_STACK_OF(void)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Per class, we have a STACK of function pointers.
|
||||||
|
*/
|
||||||
|
# define CRYPTO_EX_INDEX_SSL 0
|
||||||
|
# define CRYPTO_EX_INDEX_SSL_CTX 1
|
||||||
|
# define CRYPTO_EX_INDEX_SSL_SESSION 2
|
||||||
|
# define CRYPTO_EX_INDEX_X509 3
|
||||||
|
# define CRYPTO_EX_INDEX_X509_STORE 4
|
||||||
|
# define CRYPTO_EX_INDEX_X509_STORE_CTX 5
|
||||||
|
# define CRYPTO_EX_INDEX_DH 6
|
||||||
|
# define CRYPTO_EX_INDEX_DSA 7
|
||||||
|
# define CRYPTO_EX_INDEX_EC_KEY 8
|
||||||
|
# define CRYPTO_EX_INDEX_RSA 9
|
||||||
|
# define CRYPTO_EX_INDEX_ENGINE 10
|
||||||
|
# define CRYPTO_EX_INDEX_UI 11
|
||||||
|
# define CRYPTO_EX_INDEX_BIO 12
|
||||||
|
# define CRYPTO_EX_INDEX_APP 13
|
||||||
|
# define CRYPTO_EX_INDEX_UI_METHOD 14
|
||||||
|
# define CRYPTO_EX_INDEX_DRBG 15
|
||||||
|
# define CRYPTO_EX_INDEX__COUNT 16
|
||||||
|
|
||||||
|
/* No longer needed, so this is a no-op */
|
||||||
|
#define OPENSSL_malloc_init() while(0) continue
|
||||||
|
|
||||||
|
int CRYPTO_mem_ctrl(int mode);
|
||||||
|
|
||||||
|
# define OPENSSL_malloc(num) \
|
||||||
|
CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_zalloc(num) \
|
||||||
|
CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_realloc(addr, num) \
|
||||||
|
CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_clear_realloc(addr, old_num, num) \
|
||||||
|
CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_clear_free(addr, num) \
|
||||||
|
CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_free(addr) \
|
||||||
|
CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_memdup(str, s) \
|
||||||
|
CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_strdup(str) \
|
||||||
|
CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_strndup(str, n) \
|
||||||
|
CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_secure_malloc(num) \
|
||||||
|
CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_secure_zalloc(num) \
|
||||||
|
CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_secure_free(addr) \
|
||||||
|
CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_secure_clear_free(addr, num) \
|
||||||
|
CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_secure_actual_size(ptr) \
|
||||||
|
CRYPTO_secure_actual_size(ptr)
|
||||||
|
|
||||||
|
size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz);
|
||||||
|
size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz);
|
||||||
|
size_t OPENSSL_strnlen(const char *str, size_t maxlen);
|
||||||
|
char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len);
|
||||||
|
unsigned char *OPENSSL_hexstr2buf(const char *str, long *len);
|
||||||
|
int OPENSSL_hexchar2int(unsigned char c);
|
||||||
|
|
||||||
|
# define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type))
|
||||||
|
|
||||||
|
unsigned long OpenSSL_version_num(void);
|
||||||
|
const char *OpenSSL_version(int type);
|
||||||
|
# define OPENSSL_VERSION 0
|
||||||
|
# define OPENSSL_CFLAGS 1
|
||||||
|
# define OPENSSL_BUILT_ON 2
|
||||||
|
# define OPENSSL_PLATFORM 3
|
||||||
|
# define OPENSSL_DIR 4
|
||||||
|
# define OPENSSL_ENGINES_DIR 5
|
||||||
|
|
||||||
|
int OPENSSL_issetugid(void);
|
||||||
|
|
||||||
|
typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||||
|
int idx, long argl, void *argp);
|
||||||
|
typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||||
|
int idx, long argl, void *argp);
|
||||||
|
typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,
|
||||||
|
void *from_d, int idx, long argl, void *argp);
|
||||||
|
__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
|
||||||
|
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||||
|
CRYPTO_EX_free *free_func);
|
||||||
|
/* No longer use an index. */
|
||||||
|
int CRYPTO_free_ex_index(int class_index, int idx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a
|
||||||
|
* given class (invokes whatever per-class callbacks are applicable)
|
||||||
|
*/
|
||||||
|
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||||
|
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||||
|
const CRYPTO_EX_DATA *from);
|
||||||
|
|
||||||
|
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular
|
||||||
|
* index (relative to the class type involved)
|
||||||
|
*/
|
||||||
|
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
|
||||||
|
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
/*
|
||||||
|
* This function cleans up all "ex_data" state. It mustn't be called under
|
||||||
|
* potential race-conditions.
|
||||||
|
*/
|
||||||
|
# define CRYPTO_cleanup_all_ex_data() while(0) continue
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The old locking functions have been removed completely without compatibility
|
||||||
|
* macros. This is because the old functions either could not properly report
|
||||||
|
* errors, or the returned error values were not clearly documented.
|
||||||
|
* Replacing the locking functions with no-ops would cause race condition
|
||||||
|
* issues in the affected applications. It is far better for them to fail at
|
||||||
|
* compile time.
|
||||||
|
* On the other hand, the locking callbacks are no longer used. Consequently,
|
||||||
|
* the callback management functions can be safely replaced with no-op macros.
|
||||||
|
*/
|
||||||
|
# define CRYPTO_num_locks() (1)
|
||||||
|
# define CRYPTO_set_locking_callback(func)
|
||||||
|
# define CRYPTO_get_locking_callback() (NULL)
|
||||||
|
# define CRYPTO_set_add_lock_callback(func)
|
||||||
|
# define CRYPTO_get_add_lock_callback() (NULL)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These defines where used in combination with the old locking callbacks,
|
||||||
|
* they are not called anymore, but old code that's not called might still
|
||||||
|
* use them.
|
||||||
|
*/
|
||||||
|
# define CRYPTO_LOCK 1
|
||||||
|
# define CRYPTO_UNLOCK 2
|
||||||
|
# define CRYPTO_READ 4
|
||||||
|
# define CRYPTO_WRITE 8
|
||||||
|
|
||||||
|
/* This structure is no longer used */
|
||||||
|
typedef struct crypto_threadid_st {
|
||||||
|
int dummy;
|
||||||
|
} CRYPTO_THREADID;
|
||||||
|
/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
|
||||||
|
# define CRYPTO_THREADID_set_numeric(id, val)
|
||||||
|
# define CRYPTO_THREADID_set_pointer(id, ptr)
|
||||||
|
# define CRYPTO_THREADID_set_callback(threadid_func) (0)
|
||||||
|
# define CRYPTO_THREADID_get_callback() (NULL)
|
||||||
|
# define CRYPTO_THREADID_current(id)
|
||||||
|
# define CRYPTO_THREADID_cmp(a, b) (-1)
|
||||||
|
# define CRYPTO_THREADID_cpy(dest, src)
|
||||||
|
# define CRYPTO_THREADID_hash(id) (0UL)
|
||||||
|
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10000000L
|
||||||
|
# define CRYPTO_set_id_callback(func)
|
||||||
|
# define CRYPTO_get_id_callback() (NULL)
|
||||||
|
# define CRYPTO_thread_id() (0UL)
|
||||||
|
# endif /* OPENSSL_API_COMPAT < 0x10000000L */
|
||||||
|
|
||||||
|
# define CRYPTO_set_dynlock_create_callback(dyn_create_function)
|
||||||
|
# define CRYPTO_set_dynlock_lock_callback(dyn_lock_function)
|
||||||
|
# define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function)
|
||||||
|
# define CRYPTO_get_dynlock_create_callback() (NULL)
|
||||||
|
# define CRYPTO_get_dynlock_lock_callback() (NULL)
|
||||||
|
# define CRYPTO_get_dynlock_destroy_callback() (NULL)
|
||||||
|
# endif /* OPENSSL_API_COMPAT < 0x10100000L */
|
||||||
|
|
||||||
|
int CRYPTO_set_mem_functions(
|
||||||
|
void *(*m) (size_t, const char *, int),
|
||||||
|
void *(*r) (void *, size_t, const char *, int),
|
||||||
|
void (*f) (void *, const char *, int));
|
||||||
|
int CRYPTO_set_mem_debug(int flag);
|
||||||
|
void CRYPTO_get_mem_functions(
|
||||||
|
void *(**m) (size_t, const char *, int),
|
||||||
|
void *(**r) (void *, size_t, const char *, int),
|
||||||
|
void (**f) (void *, const char *, int));
|
||||||
|
|
||||||
|
void *CRYPTO_malloc(size_t num, const char *file, int line);
|
||||||
|
void *CRYPTO_zalloc(size_t num, const char *file, int line);
|
||||||
|
void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);
|
||||||
|
char *CRYPTO_strdup(const char *str, const char *file, int line);
|
||||||
|
char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);
|
||||||
|
void CRYPTO_free(void *ptr, const char *file, int line);
|
||||||
|
void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line);
|
||||||
|
void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line);
|
||||||
|
void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num,
|
||||||
|
const char *file, int line);
|
||||||
|
|
||||||
|
int CRYPTO_secure_malloc_init(size_t sz, int minsize);
|
||||||
|
int CRYPTO_secure_malloc_done(void);
|
||||||
|
void *CRYPTO_secure_malloc(size_t num, const char *file, int line);
|
||||||
|
void *CRYPTO_secure_zalloc(size_t num, const char *file, int line);
|
||||||
|
void CRYPTO_secure_free(void *ptr, const char *file, int line);
|
||||||
|
void CRYPTO_secure_clear_free(void *ptr, size_t num,
|
||||||
|
const char *file, int line);
|
||||||
|
int CRYPTO_secure_allocated(const void *ptr);
|
||||||
|
int CRYPTO_secure_malloc_initialized(void);
|
||||||
|
size_t CRYPTO_secure_actual_size(void *ptr);
|
||||||
|
size_t CRYPTO_secure_used(void);
|
||||||
|
|
||||||
|
void OPENSSL_cleanse(void *ptr, size_t len);
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||||
|
# define OPENSSL_mem_debug_push(info) \
|
||||||
|
CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE)
|
||||||
|
# define OPENSSL_mem_debug_pop() \
|
||||||
|
CRYPTO_mem_debug_pop()
|
||||||
|
int CRYPTO_mem_debug_push(const char *info, const char *file, int line);
|
||||||
|
int CRYPTO_mem_debug_pop(void);
|
||||||
|
void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount);
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Debugging functions (enabled by CRYPTO_set_mem_debug(1))
|
||||||
|
* The flag argument has the following significance:
|
||||||
|
* 0: called before the actual memory allocation has taken place
|
||||||
|
* 1: called after the actual memory allocation has taken place
|
||||||
|
*/
|
||||||
|
void CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag,
|
||||||
|
const char *file, int line);
|
||||||
|
void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag,
|
||||||
|
const char *file, int line);
|
||||||
|
void CRYPTO_mem_debug_free(void *addr, int flag,
|
||||||
|
const char *file, int line);
|
||||||
|
|
||||||
|
int CRYPTO_mem_leaks_cb(int (*cb) (const char *str, size_t len, void *u),
|
||||||
|
void *u);
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
int CRYPTO_mem_leaks_fp(FILE *);
|
||||||
|
# endif
|
||||||
|
int CRYPTO_mem_leaks(BIO *bio);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* die if we have to */
|
||||||
|
ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line);
|
||||||
|
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||||
|
# define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l))
|
||||||
|
# endif
|
||||||
|
# define OPENSSL_assert(e) \
|
||||||
|
(void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1))
|
||||||
|
|
||||||
|
int OPENSSL_isservice(void);
|
||||||
|
|
||||||
|
int FIPS_mode(void);
|
||||||
|
int FIPS_mode_set(int r);
|
||||||
|
|
||||||
|
void OPENSSL_init(void);
|
||||||
|
# ifdef OPENSSL_SYS_UNIX
|
||||||
|
void OPENSSL_fork_prepare(void);
|
||||||
|
void OPENSSL_fork_parent(void);
|
||||||
|
void OPENSSL_fork_child(void);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
|
||||||
|
int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
|
||||||
|
int OPENSSL_gmtime_diff(int *pday, int *psec,
|
||||||
|
const struct tm *from, const struct tm *to);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.
|
||||||
|
* It takes an amount of time dependent on |len|, but independent of the
|
||||||
|
* contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements
|
||||||
|
* into a defined order as the return value when a != b is undefined, other
|
||||||
|
* than to be non-zero.
|
||||||
|
*/
|
||||||
|
int CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len);
|
||||||
|
|
||||||
|
/* Standard initialisation options */
|
||||||
|
# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L
|
||||||
|
# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L
|
||||||
|
# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L
|
||||||
|
# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L
|
||||||
|
# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0x00000010L
|
||||||
|
# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0x00000020L
|
||||||
|
# define OPENSSL_INIT_LOAD_CONFIG 0x00000040L
|
||||||
|
# define OPENSSL_INIT_NO_LOAD_CONFIG 0x00000080L
|
||||||
|
# define OPENSSL_INIT_ASYNC 0x00000100L
|
||||||
|
# define OPENSSL_INIT_ENGINE_RDRAND 0x00000200L
|
||||||
|
# define OPENSSL_INIT_ENGINE_DYNAMIC 0x00000400L
|
||||||
|
# define OPENSSL_INIT_ENGINE_OPENSSL 0x00000800L
|
||||||
|
# define OPENSSL_INIT_ENGINE_CRYPTODEV 0x00001000L
|
||||||
|
# define OPENSSL_INIT_ENGINE_CAPI 0x00002000L
|
||||||
|
# define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L
|
||||||
|
# define OPENSSL_INIT_ENGINE_AFALG 0x00008000L
|
||||||
|
/* OPENSSL_INIT_ZLIB 0x00010000L */
|
||||||
|
# define OPENSSL_INIT_ATFORK 0x00020000L
|
||||||
|
/* OPENSSL_INIT_BASE_ONLY 0x00040000L */
|
||||||
|
# define OPENSSL_INIT_NO_ATEXIT 0x00080000L
|
||||||
|
/* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */
|
||||||
|
/* Max OPENSSL_INIT flag value is 0x80000000 */
|
||||||
|
|
||||||
|
/* openssl and dasync not counted as builtin */
|
||||||
|
# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \
|
||||||
|
(OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \
|
||||||
|
| OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \
|
||||||
|
OPENSSL_INIT_ENGINE_PADLOCK)
|
||||||
|
|
||||||
|
|
||||||
|
/* Library initialisation functions */
|
||||||
|
void OPENSSL_cleanup(void);
|
||||||
|
int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
|
||||||
|
int OPENSSL_atexit(void (*handler)(void));
|
||||||
|
void OPENSSL_thread_stop(void);
|
||||||
|
|
||||||
|
/* Low-level control of initialization */
|
||||||
|
OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void);
|
||||||
|
# ifndef OPENSSL_NO_STDIO
|
||||||
|
int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
|
||||||
|
const char *config_filename);
|
||||||
|
void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings,
|
||||||
|
unsigned long flags);
|
||||||
|
int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings,
|
||||||
|
const char *config_appname);
|
||||||
|
# endif
|
||||||
|
void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings);
|
||||||
|
|
||||||
|
# if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG)
|
||||||
|
# if defined(_WIN32)
|
||||||
|
# if defined(BASETYPES) || defined(_WINDEF_H)
|
||||||
|
/* application has to include <windows.h> in order to use this */
|
||||||
|
typedef DWORD CRYPTO_THREAD_LOCAL;
|
||||||
|
typedef DWORD CRYPTO_THREAD_ID;
|
||||||
|
|
||||||
|
typedef LONG CRYPTO_ONCE;
|
||||||
|
# define CRYPTO_ONCE_STATIC_INIT 0
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# include <pthread.h>
|
||||||
|
typedef pthread_once_t CRYPTO_ONCE;
|
||||||
|
typedef pthread_key_t CRYPTO_THREAD_LOCAL;
|
||||||
|
typedef pthread_t CRYPTO_THREAD_ID;
|
||||||
|
|
||||||
|
# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if !defined(CRYPTO_ONCE_STATIC_INIT)
|
||||||
|
typedef unsigned int CRYPTO_ONCE;
|
||||||
|
typedef unsigned int CRYPTO_THREAD_LOCAL;
|
||||||
|
typedef unsigned int CRYPTO_THREAD_ID;
|
||||||
|
# define CRYPTO_ONCE_STATIC_INIT 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void));
|
||||||
|
|
||||||
|
int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *));
|
||||||
|
void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key);
|
||||||
|
int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val);
|
||||||
|
int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key);
|
||||||
|
|
||||||
|
CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void);
|
||||||
|
int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b);
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
57
lib/OpenSSL/include/openssl/cryptoerr.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Generated by util/mkerr.pl DO NOT EDIT
|
||||||
|
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CRYPTOERR_H
|
||||||
|
# define HEADER_CRYPTOERR_H
|
||||||
|
|
||||||
|
# ifndef HEADER_SYMHACKS_H
|
||||||
|
# include <openssl/symhacks.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
# endif
|
||||||
|
int ERR_load_CRYPTO_strings(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CRYPTO function codes.
|
||||||
|
*/
|
||||||
|
# define CRYPTO_F_CMAC_CTX_NEW 120
|
||||||
|
# define CRYPTO_F_CRYPTO_DUP_EX_DATA 110
|
||||||
|
# define CRYPTO_F_CRYPTO_FREE_EX_DATA 111
|
||||||
|
# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
|
||||||
|
# define CRYPTO_F_CRYPTO_MEMDUP 115
|
||||||
|
# define CRYPTO_F_CRYPTO_NEW_EX_DATA 112
|
||||||
|
# define CRYPTO_F_CRYPTO_OCB128_COPY_CTX 121
|
||||||
|
# define CRYPTO_F_CRYPTO_OCB128_INIT 122
|
||||||
|
# define CRYPTO_F_CRYPTO_SET_EX_DATA 102
|
||||||
|
# define CRYPTO_F_FIPS_MODE_SET 109
|
||||||
|
# define CRYPTO_F_GET_AND_LOCK 113
|
||||||
|
# define CRYPTO_F_OPENSSL_ATEXIT 114
|
||||||
|
# define CRYPTO_F_OPENSSL_BUF2HEXSTR 117
|
||||||
|
# define CRYPTO_F_OPENSSL_FOPEN 119
|
||||||
|
# define CRYPTO_F_OPENSSL_HEXSTR2BUF 118
|
||||||
|
# define CRYPTO_F_OPENSSL_INIT_CRYPTO 116
|
||||||
|
# define CRYPTO_F_OPENSSL_LH_NEW 126
|
||||||
|
# define CRYPTO_F_OPENSSL_SK_DEEP_COPY 127
|
||||||
|
# define CRYPTO_F_OPENSSL_SK_DUP 128
|
||||||
|
# define CRYPTO_F_PKEY_HMAC_INIT 123
|
||||||
|
# define CRYPTO_F_PKEY_POLY1305_INIT 124
|
||||||
|
# define CRYPTO_F_PKEY_SIPHASH_INIT 125
|
||||||
|
# define CRYPTO_F_SK_RESERVE 129
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CRYPTO reason codes.
|
||||||
|
*/
|
||||||
|
# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101
|
||||||
|
# define CRYPTO_R_ILLEGAL_HEX_DIGIT 102
|
||||||
|
# define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103
|
||||||
|
|
||||||
|
#endif
|
474
lib/OpenSSL/include/openssl/ct.h
Normal file
@ -0,0 +1,474 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_CT_H
|
||||||
|
# define HEADER_CT_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_CT
|
||||||
|
# include <openssl/ossl_typ.h>
|
||||||
|
# include <openssl/safestack.h>
|
||||||
|
# include <openssl/x509.h>
|
||||||
|
# include <openssl/cterr.h>
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Minimum RSA key size, from RFC6962 */
|
||||||
|
# define SCT_MIN_RSA_BITS 2048
|
||||||
|
|
||||||
|
/* All hashes are SHA256 in v1 of Certificate Transparency */
|
||||||
|
# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CT_LOG_ENTRY_TYPE_NOT_SET = -1,
|
||||||
|
CT_LOG_ENTRY_TYPE_X509 = 0,
|
||||||
|
CT_LOG_ENTRY_TYPE_PRECERT = 1
|
||||||
|
} ct_log_entry_type_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SCT_VERSION_NOT_SET = -1,
|
||||||
|
SCT_VERSION_V1 = 0
|
||||||
|
} sct_version_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SCT_SOURCE_UNKNOWN,
|
||||||
|
SCT_SOURCE_TLS_EXTENSION,
|
||||||
|
SCT_SOURCE_X509V3_EXTENSION,
|
||||||
|
SCT_SOURCE_OCSP_STAPLED_RESPONSE
|
||||||
|
} sct_source_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SCT_VALIDATION_STATUS_NOT_SET,
|
||||||
|
SCT_VALIDATION_STATUS_UNKNOWN_LOG,
|
||||||
|
SCT_VALIDATION_STATUS_VALID,
|
||||||
|
SCT_VALIDATION_STATUS_INVALID,
|
||||||
|
SCT_VALIDATION_STATUS_UNVERIFIED,
|
||||||
|
SCT_VALIDATION_STATUS_UNKNOWN_VERSION
|
||||||
|
} sct_validation_status_t;
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(SCT)
|
||||||
|
DEFINE_STACK_OF(CTLOG)
|
||||||
|
|
||||||
|
/******************************************
|
||||||
|
* CT policy evaluation context functions *
|
||||||
|
******************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new, empty policy evaluation context.
|
||||||
|
* The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished
|
||||||
|
* with the CT_POLICY_EVAL_CTX.
|
||||||
|
*/
|
||||||
|
CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void);
|
||||||
|
|
||||||
|
/* Deletes a policy evaluation context and anything it owns. */
|
||||||
|
void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx);
|
||||||
|
|
||||||
|
/* Gets the peer certificate that the SCTs are for */
|
||||||
|
X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the certificate associated with the received SCTs.
|
||||||
|
* Increments the reference count of cert.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert);
|
||||||
|
|
||||||
|
/* Gets the issuer of the aforementioned certificate */
|
||||||
|
X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the issuer of the certificate associated with the received SCTs.
|
||||||
|
* Increments the reference count of issuer.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer);
|
||||||
|
|
||||||
|
/* Gets the CT logs that are trusted sources of SCTs */
|
||||||
|
const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx);
|
||||||
|
|
||||||
|
/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */
|
||||||
|
void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx,
|
||||||
|
CTLOG_STORE *log_store);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the time, in milliseconds since the Unix epoch, that will be used as the
|
||||||
|
* current time when checking whether an SCT was issued in the future.
|
||||||
|
* Such SCTs will fail validation, as required by RFC6962.
|
||||||
|
*/
|
||||||
|
uint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the time to evaluate SCTs against, in milliseconds since the Unix epoch.
|
||||||
|
* If an SCT's timestamp is after this time, it will be interpreted as having
|
||||||
|
* been issued in the future. RFC6962 states that "TLS clients MUST reject SCTs
|
||||||
|
* whose timestamp is in the future", so an SCT will not validate in this case.
|
||||||
|
*/
|
||||||
|
void CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms);
|
||||||
|
|
||||||
|
/*****************
|
||||||
|
* SCT functions *
|
||||||
|
*****************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new, blank SCT.
|
||||||
|
* The caller is responsible for calling SCT_free when finished with the SCT.
|
||||||
|
*/
|
||||||
|
SCT *SCT_new(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new SCT from some base64-encoded strings.
|
||||||
|
* The caller is responsible for calling SCT_free when finished with the SCT.
|
||||||
|
*/
|
||||||
|
SCT *SCT_new_from_base64(unsigned char version,
|
||||||
|
const char *logid_base64,
|
||||||
|
ct_log_entry_type_t entry_type,
|
||||||
|
uint64_t timestamp,
|
||||||
|
const char *extensions_base64,
|
||||||
|
const char *signature_base64);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Frees the SCT and the underlying data structures.
|
||||||
|
*/
|
||||||
|
void SCT_free(SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free a stack of SCTs, and the underlying SCTs themselves.
|
||||||
|
* Intended to be compatible with X509V3_EXT_FREE.
|
||||||
|
*/
|
||||||
|
void SCT_LIST_free(STACK_OF(SCT) *a);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the version of the SCT.
|
||||||
|
*/
|
||||||
|
sct_version_t SCT_get_version(const SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the version of an SCT.
|
||||||
|
* Returns 1 on success, 0 if the version is unrecognized.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set_version(SCT *sct, sct_version_t version);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the log entry type of the SCT.
|
||||||
|
*/
|
||||||
|
ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the log entry type of an SCT.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the ID of the log that an SCT came from.
|
||||||
|
* Ownership of the log ID remains with the SCT.
|
||||||
|
* Returns the length of the log ID.
|
||||||
|
*/
|
||||||
|
size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the log ID of an SCT to point directly to the *log_id specified.
|
||||||
|
* The SCT takes ownership of the specified pointer.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the log ID of an SCT.
|
||||||
|
* This makes a copy of the log_id.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id,
|
||||||
|
size_t log_id_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the timestamp for the SCT (epoch time in milliseconds).
|
||||||
|
*/
|
||||||
|
uint64_t SCT_get_timestamp(const SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the timestamp of an SCT (epoch time in milliseconds).
|
||||||
|
*/
|
||||||
|
void SCT_set_timestamp(SCT *sct, uint64_t timestamp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the NID for the signature used by the SCT.
|
||||||
|
* For CT v1, this will be either NID_sha256WithRSAEncryption or
|
||||||
|
* NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset).
|
||||||
|
*/
|
||||||
|
int SCT_get_signature_nid(const SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the signature type of an SCT
|
||||||
|
* For CT v1, this should be either NID_sha256WithRSAEncryption or
|
||||||
|
* NID_ecdsa_with_SHA256.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set_signature_nid(SCT *sct, int nid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set *ext to point to the extension data for the SCT. ext must not be NULL.
|
||||||
|
* The SCT retains ownership of this pointer.
|
||||||
|
* Returns length of the data pointed to.
|
||||||
|
*/
|
||||||
|
size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the extensions of an SCT to point directly to the *ext specified.
|
||||||
|
* The SCT takes ownership of the specified pointer.
|
||||||
|
*/
|
||||||
|
void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the extensions of an SCT.
|
||||||
|
* This takes a copy of the ext.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext,
|
||||||
|
size_t ext_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set *sig to point to the signature for the SCT. sig must not be NULL.
|
||||||
|
* The SCT retains ownership of this pointer.
|
||||||
|
* Returns length of the data pointed to.
|
||||||
|
*/
|
||||||
|
size_t SCT_get0_signature(const SCT *sct, unsigned char **sig);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the signature of an SCT to point directly to the *sig specified.
|
||||||
|
* The SCT takes ownership of the specified pointer.
|
||||||
|
*/
|
||||||
|
void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the signature of an SCT to be a copy of the *sig specified.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig,
|
||||||
|
size_t sig_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The origin of this SCT, e.g. TLS extension, OCSP response, etc.
|
||||||
|
*/
|
||||||
|
sct_source_t SCT_get_source(const SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the origin of this SCT, e.g. TLS extension, OCSP response, etc.
|
||||||
|
* Returns 1 on success, 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int SCT_set_source(SCT *sct, sct_source_t source);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a text string describing the validation status of |sct|.
|
||||||
|
*/
|
||||||
|
const char *SCT_validation_status_string(const SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pretty-prints an |sct| to |out|.
|
||||||
|
* It will be indented by the number of spaces specified by |indent|.
|
||||||
|
* If |logs| is not NULL, it will be used to lookup the CT log that the SCT came
|
||||||
|
* from, so that the log name can be printed.
|
||||||
|
*/
|
||||||
|
void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pretty-prints an |sct_list| to |out|.
|
||||||
|
* It will be indented by the number of spaces specified by |indent|.
|
||||||
|
* SCTs will be delimited by |separator|.
|
||||||
|
* If |logs| is not NULL, it will be used to lookup the CT log that each SCT
|
||||||
|
* came from, so that the log names can be printed.
|
||||||
|
*/
|
||||||
|
void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent,
|
||||||
|
const char *separator, const CTLOG_STORE *logs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the last result of validating this SCT.
|
||||||
|
* If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET.
|
||||||
|
*/
|
||||||
|
sct_validation_status_t SCT_get_validation_status(const SCT *sct);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Validates the given SCT with the provided context.
|
||||||
|
* Sets the "validation_status" field of the SCT.
|
||||||
|
* Returns 1 if the SCT is valid and the signature verifies.
|
||||||
|
* Returns 0 if the SCT is invalid or could not be verified.
|
||||||
|
* Returns -1 if an error occurs.
|
||||||
|
*/
|
||||||
|
__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Validates the given list of SCTs with the provided context.
|
||||||
|
* Sets the "validation_status" field of each SCT.
|
||||||
|
* Returns 1 if there are no invalid SCTs and all signatures verify.
|
||||||
|
* Returns 0 if at least one SCT is invalid or could not be verified.
|
||||||
|
* Returns a negative integer if an error occurs.
|
||||||
|
*/
|
||||||
|
__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts,
|
||||||
|
CT_POLICY_EVAL_CTX *ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************
|
||||||
|
* SCT parsing and serialisation *
|
||||||
|
*********************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Serialize (to TLS format) a stack of SCTs and return the length.
|
||||||
|
* "a" must not be NULL.
|
||||||
|
* If "pp" is NULL, just return the length of what would have been serialized.
|
||||||
|
* If "pp" is not NULL and "*pp" is null, function will allocate a new pointer
|
||||||
|
* for data that caller is responsible for freeing (only if function returns
|
||||||
|
* successfully).
|
||||||
|
* If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring
|
||||||
|
* that "*pp" is large enough to accept all of the serialized data.
|
||||||
|
* Returns < 0 on error, >= 0 indicating bytes written (or would have been)
|
||||||
|
* on success.
|
||||||
|
*/
|
||||||
|
__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert TLS format SCT list to a stack of SCTs.
|
||||||
|
* If "a" or "*a" is NULL, a new stack will be created that the caller is
|
||||||
|
* responsible for freeing (by calling SCT_LIST_free).
|
||||||
|
* "**pp" and "*pp" must not be NULL.
|
||||||
|
* Upon success, "*pp" will point to after the last bytes read, and a stack
|
||||||
|
* will be returned.
|
||||||
|
* Upon failure, a NULL pointer will be returned, and the position of "*pp" is
|
||||||
|
* not defined.
|
||||||
|
*/
|
||||||
|
STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
|
||||||
|
size_t len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Serialize (to DER format) a stack of SCTs and return the length.
|
||||||
|
* "a" must not be NULL.
|
||||||
|
* If "pp" is NULL, just returns the length of what would have been serialized.
|
||||||
|
* If "pp" is not NULL and "*pp" is null, function will allocate a new pointer
|
||||||
|
* for data that caller is responsible for freeing (only if function returns
|
||||||
|
* successfully).
|
||||||
|
* If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring
|
||||||
|
* that "*pp" is large enough to accept all of the serialized data.
|
||||||
|
* Returns < 0 on error, >= 0 indicating bytes written (or would have been)
|
||||||
|
* on success.
|
||||||
|
*/
|
||||||
|
__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses an SCT list in DER format and returns it.
|
||||||
|
* If "a" or "*a" is NULL, a new stack will be created that the caller is
|
||||||
|
* responsible for freeing (by calling SCT_LIST_free).
|
||||||
|
* "**pp" and "*pp" must not be NULL.
|
||||||
|
* Upon success, "*pp" will point to after the last bytes read, and a stack
|
||||||
|
* will be returned.
|
||||||
|
* Upon failure, a NULL pointer will be returned, and the position of "*pp" is
|
||||||
|
* not defined.
|
||||||
|
*/
|
||||||
|
STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
|
||||||
|
long len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Serialize (to TLS format) an |sct| and write it to |out|.
|
||||||
|
* If |out| is null, no SCT will be output but the length will still be returned.
|
||||||
|
* If |out| points to a null pointer, a string will be allocated to hold the
|
||||||
|
* TLS-format SCT. It is the responsibility of the caller to free it.
|
||||||
|
* If |out| points to an allocated string, the TLS-format SCT will be written
|
||||||
|
* to it.
|
||||||
|
* The length of the SCT in TLS format will be returned.
|
||||||
|
*/
|
||||||
|
__owur int i2o_SCT(const SCT *sct, unsigned char **out);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses an SCT in TLS format and returns it.
|
||||||
|
* If |psct| is not null, it will end up pointing to the parsed SCT. If it
|
||||||
|
* already points to a non-null pointer, the pointer will be free'd.
|
||||||
|
* |in| should be a pointer to a string containing the TLS-format SCT.
|
||||||
|
* |in| will be advanced to the end of the SCT if parsing succeeds.
|
||||||
|
* |len| should be the length of the SCT in |in|.
|
||||||
|
* Returns NULL if an error occurs.
|
||||||
|
* If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len'
|
||||||
|
* fields will be populated (with |in| and |len| respectively).
|
||||||
|
*/
|
||||||
|
SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len);
|
||||||
|
|
||||||
|
/********************
|
||||||
|
* CT log functions *
|
||||||
|
********************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new CT log instance with the given |public_key| and |name|.
|
||||||
|
* Takes ownership of |public_key| but copies |name|.
|
||||||
|
* Returns NULL if malloc fails or if |public_key| cannot be converted to DER.
|
||||||
|
* Should be deleted by the caller using CTLOG_free when no longer needed.
|
||||||
|
*/
|
||||||
|
CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER
|
||||||
|
* in |pkey_base64|. The |name| is a string to help users identify this log.
|
||||||
|
* Returns 1 on success, 0 on failure.
|
||||||
|
* Should be deleted by the caller using CTLOG_free when no longer needed.
|
||||||
|
*/
|
||||||
|
int CTLOG_new_from_base64(CTLOG ** ct_log,
|
||||||
|
const char *pkey_base64, const char *name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deletes a CT log instance and its fields.
|
||||||
|
*/
|
||||||
|
void CTLOG_free(CTLOG *log);
|
||||||
|
|
||||||
|
/* Gets the name of the CT log */
|
||||||
|
const char *CTLOG_get0_name(const CTLOG *log);
|
||||||
|
/* Gets the ID of the CT log */
|
||||||
|
void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id,
|
||||||
|
size_t *log_id_len);
|
||||||
|
/* Gets the public key of the CT log */
|
||||||
|
EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log);
|
||||||
|
|
||||||
|
/**************************
|
||||||
|
* CT log store functions *
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new CT log store.
|
||||||
|
* Should be deleted by the caller using CTLOG_STORE_free when no longer needed.
|
||||||
|
*/
|
||||||
|
CTLOG_STORE *CTLOG_STORE_new(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deletes a CT log store and all of the CT log instances held within.
|
||||||
|
*/
|
||||||
|
void CTLOG_STORE_free(CTLOG_STORE *store);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finds a CT log in the store based on its log ID.
|
||||||
|
* Returns the CT log, or NULL if no match is found.
|
||||||
|
*/
|
||||||
|
const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store,
|
||||||
|
const uint8_t *log_id,
|
||||||
|
size_t log_id_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Loads a CT log list into a |store| from a |file|.
|
||||||
|
* Returns 1 if loading is successful, or 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Loads the default CT log list into a |store|.
|
||||||
|
* Returns 1 if loading is successful, or 0 otherwise.
|
||||||
|
*/
|
||||||
|
__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store);
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|