openssl stuff
This commit is contained in:
Родитель
b1f669e368
Коммит
bb0870f4c9
|
@ -395,3 +395,4 @@ __pycache__/
|
|||
# to avoid seeing deleted: ../lib/zlib/zconf.h in the working directory
|
||||
# run git update-index --assume-unchanged lib/zlib/zconf.h
|
||||
lib/zlib
|
||||
src/inc/AppxCerts.hpp
|
|
@ -1,53 +0,0 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(lldb) Launch MakeXPlat",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/bin/MakeXPlat",
|
||||
"args": ["unpack",
|
||||
"-d" ,"${workspaceRoot}/test/unpack",
|
||||
"-p", "${workspaceRoot}/test/appx/StoreSigned_Desktop_x64_MoviesTV.appx",
|
||||
"-sv"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/bin",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
{
|
||||
"name": "(lldb) Launch ExtractContentsSample",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/bin/ExtractContentsSample",
|
||||
"args": [
|
||||
"${workspaceRoot}/test/appx/StoreSigned_Desktop_x64_MoviesTV.appx",
|
||||
"${workspaceRoot}/test/unpack" ],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/bin",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
{
|
||||
"name": "(Windows) Launch",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}\\.vs\\bin\\MakeXPlat",
|
||||
"symbolSearchPath" : "${workspaceRoot}\\.vs\\bin",
|
||||
"logging": {
|
||||
"moduleLoad": false,
|
||||
"trace": true
|
||||
},
|
||||
"args": ["unpack",
|
||||
"-d" ,"${workspaceRoot}\\test\\unpack",
|
||||
"-p", "${workspaceRoot}\\test\\appx\\UnsignedZip64WithCI-APPX_E_MISSING_REQUIRED_FILE.appx" ],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}",
|
||||
"environment": [],
|
||||
"externalConsole": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -12,3 +12,29 @@ add_subdirectory(xPlatAppx)
|
|||
add_subdirectory(MakeXplat)
|
||||
|
||||
ADD_DEPENDENCIES(MakeXplat xPlatAppx)
|
||||
|
||||
# Create header for BlockMap schemas
|
||||
|
||||
file(READ "${CMAKE_PROJECT_ROOT}/certs/base64_MSFT_RCA_2010.cer" BASE64_MSFT_RCA_2010)
|
||||
file(READ "${CMAKE_PROJECT_ROOT}/certs/base64_MSFT_RCA_2011.cer" BASE64_MSFT_RCA_2011)
|
||||
file(READ "${CMAKE_PROJECT_ROOT}/certs/base64_STORE_PCA_2011.cer" BASE64_STORE_PCA_2011)
|
||||
file(READ "${CMAKE_PROJECT_ROOT}/certs/base64_Windows_Production.cer" BASE64_WINDOWS_PRODUCTION)
|
||||
file(READ "${CMAKE_PROJECT_ROOT}/certs/base64_Windows_Production_PCA_2011.cer" BASE64_WINDOWS_PRODUCTION_PCA_2011)
|
||||
|
||||
set(APPX_CERTS "// This file is generated by CMake and contains certs for parsing the AppxBlockMap.xml. Do not edit!!
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace xPlat {
|
||||
|
||||
std::map<std::string, std::string> appxCerts = {
|
||||
{\"BASE64_MSFT_RCA_2010\", R\"(${BASE64_MSFT_RCA_2010})\"},
|
||||
{\"BASE64_MSFT_RCA_2011\", R\"(${BASE64_MSFT_RCA_2011})\"},
|
||||
{\"BASE64_STORE_PCA_2011\", R\"(${BASE64_STORE_PCA_2011})\"},
|
||||
{\"BASE64_WINDOWS_PRODUCTION\", R\"(${BASE64_WINDOWS_PRODUCTION})\"},
|
||||
{\"BASE64_WINDOWS_PRODUCTION_PCA_2011\", R\"(${BASE64_WINDOWS_PRODUCTION_PCA_2011})\"}
|
||||
};
|
||||
|
||||
}")
|
||||
file(WRITE "${CMAKE_PROJECT_ROOT}/src/inc/AppxCerts.hpp" "${APPX_CERTS}")
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(lldb) Launch MakeXPlat",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/Users/admin/code/xPlatAppx/build/bin/MakeXPlat",
|
||||
"args": ["unpack",
|
||||
"-d" ,"/Users/admin/code/xPlatAppx/test/unpack",
|
||||
"-p", "/Users/admin/code/xPlatAppx/test/appx/StoreSigned_Desktop_x64_MoviesTV.appx",
|
||||
"-sv"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/Users/admin/code/xPlatAppx/build/bin",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
{
|
||||
"name": "(lldb) Launch ExtractContentsSample",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/bin/ExtractContentsSample",
|
||||
"args": [
|
||||
"${workspaceRoot}/test/appx/StoreSigned_Desktop_x64_MoviesTV.appx",
|
||||
"${workspaceRoot}/test/unpack" ],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/bin",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
{
|
||||
"name": "(Windows) Launch",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}\\.vs\\bin\\MakeXPlat",
|
||||
"symbolSearchPath" : "${workspaceRoot}\\.vs\\bin",
|
||||
"logging": {
|
||||
"moduleLoad": false,
|
||||
"trace": true
|
||||
},
|
||||
"args": ["unpack",
|
||||
"-d" ,"${workspaceRoot}\\test\\unpack",
|
||||
"-p", "${workspaceRoot}\\test\\appx\\UnsignedZip64WithCI-APPX_E_MISSING_REQUIRED_FILE.appx" ],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}",
|
||||
"environment": [],
|
||||
"externalConsole": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -2,6 +2,9 @@
|
|||
#include "Exceptions.hpp"
|
||||
#include "FileStream.hpp"
|
||||
#include "SignatureValidator.hpp"
|
||||
#include "AppxCerts.hpp"
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/objects.h>
|
||||
|
@ -27,6 +30,60 @@ namespace xPlat
|
|||
return retValue;
|
||||
}
|
||||
|
||||
static void ConvertBase64Certificate(std::string base64Cert, std::vector<std::uint8_t>& )
|
||||
{
|
||||
std::string result;
|
||||
try
|
||||
{
|
||||
std::regex r("^(?!-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----)([a-zA-Z0-9+/]+)$");
|
||||
std::smatch match;
|
||||
if (std::regex_search(base64Cert, match, r) && match.size() > 1)
|
||||
{
|
||||
result = match.str(1);
|
||||
}
|
||||
}
|
||||
catch (std::regex_error& e)
|
||||
{
|
||||
// Syntax error in the regular expression
|
||||
std::cout << "syntax error";
|
||||
}
|
||||
|
||||
#ifdef DISABLED
|
||||
regex_match(input,integer);
|
||||
|
||||
BIO *b64 = BIO_new(BIO_f_base64());
|
||||
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
|
||||
BIO *mem = BIO_new(BIO_f_buffer());
|
||||
BIO_push(b64, mem);
|
||||
BIO_push(mem, file);
|
||||
|
||||
// write data
|
||||
bool done = false;
|
||||
int res = 0;
|
||||
while (!done)
|
||||
{
|
||||
res = ;
|
||||
|
||||
if(BIO_write(b64, input, leni) <= 0 && BIO_should_retry(b64)){
|
||||
continue;
|
||||
}
|
||||
else // encoding failed
|
||||
{
|
||||
/* Handle Error!!! */
|
||||
}
|
||||
}
|
||||
else // success!
|
||||
done = true;
|
||||
}
|
||||
|
||||
BIO_flush(b64);
|
||||
BIO_pop(b64);
|
||||
BIO_free_all(b64);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool SignatureValidator::Validate(
|
||||
/*in*/ APPX_VALIDATION_OPTION option,
|
||||
/*in*/ IStream *stream,
|
||||
|
@ -52,6 +109,18 @@ namespace xPlat
|
|||
ThrowHrIfFailed(stream->Read(buffer.data(), streamSize, &actualRead));
|
||||
ThrowErrorIf(Error::AppxSignatureInvalid, (actualRead != streamSize), "read error");
|
||||
|
||||
std::map<std::string, std::string>::iterator it;
|
||||
for ( it = appxCerts.begin(); it != appxCerts.end(); it++ )
|
||||
{
|
||||
std::vector<std::uint8_t> cert;
|
||||
ConvertBase64Certificate(it->second, cert);
|
||||
|
||||
std::cout << it->first // string (key)
|
||||
<< ':'
|
||||
<< it->second // string's value
|
||||
<< std::endl ;
|
||||
}
|
||||
|
||||
// TODO: read digests
|
||||
X509_STORE *store = nullptr;
|
||||
STACK_OF(X509) *other = nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче