-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c1e07d
commit c5106d1
Showing
6 changed files
with
677 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.a | ||
*.o | ||
.* | ||
*.swp | ||
*~ | ||
obj | ||
cscope.* | ||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
project(parsecat) | ||
|
||
cmake_minimum_required(VERSION 3.5) | ||
|
||
# Create the compile command database for clang by default | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
set(CMAKE_MODULE_PATH | ||
${CMAKE_SOURCE_DIR}/cmake/Modules | ||
) | ||
|
||
include(CheckCCompilerFlag) | ||
if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)") | ||
|
||
# add -Wconversion ? | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute -Wcast-align -Wcast-qual") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers") | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=pointer-arith -Werror=declaration-after-statement") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration -Werror=write-strings") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast") | ||
# -Werror=strict-aliasing is broken | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrict-aliasing -Wstrict-aliasing=2") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrict-overflow -Wstrict-overflow=5 -Werror=strict-overflow") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE") | ||
|
||
# with -fPIC | ||
check_c_compiler_flag("-fPIC" WITH_FPIC) | ||
if (WITH_FPIC) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") | ||
endif (WITH_FPIC) | ||
|
||
if (CMAKE_BUILD_TYPE) | ||
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) | ||
if (CMAKE_BUILD_TYPE_LOWER MATCHES (release|relwithdebinfo|minsizerel)) | ||
check_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE) | ||
if (WITH_FORTIFY_SOURCE) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-D_FORTIFY_SOURCE=2") | ||
endif (WITH_FORTIFY_SOURCE) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=uninitialized") | ||
endif() | ||
endif() | ||
endif (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)") | ||
|
||
find_package(GnuTLS REQUIRED) | ||
find_package(Libtasn1 REQUIRED) | ||
|
||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# - Try to find Libtasn1 | ||
# Once done this will define | ||
# | ||
# LIBTASN1_FOUND - system has Libtasn1 | ||
# LIBTASN1_INCLUDE_DIR - the Libtasn1 include directory | ||
# LIBTASN1_LIBRARIES - Link these to use Libtasn1 | ||
# LIBTASN1_DEFINITIONS - Compiler switches required for using Libtasn1 | ||
# | ||
#============================================================================= | ||
# Copyright (c) 2016 Andreas Schneider <asn@samba.org> | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file Copyright.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# | ||
|
||
if (UNIX) | ||
find_package(PkgConfig) | ||
if (PKG_CONFIG_FOUND) | ||
pkg_check_modules(_LIBTASN1 libtasn1) | ||
endif (PKG_CONFIG_FOUND) | ||
endif (UNIX) | ||
|
||
find_path(LIBTASN1_INCLUDE_DIR | ||
NAMES | ||
libtasn1.h | ||
PATHS | ||
${_LIBTASN1_INCLUDEDIR} | ||
) | ||
|
||
find_library(TASN1_LIBRARY | ||
NAMES | ||
tasn1 | ||
PATHS | ||
${_LIBTASN1_LIBDIR} | ||
) | ||
|
||
if (TASN1_LIBRARY) | ||
set(LIBTASN1_LIBRARIES | ||
${LIBTASN1_LIBRARIES} | ||
${TASN1_LIBRARY} | ||
) | ||
endif (TASN1_LIBRARY) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Libtasn1 DEFAULT_MSG LIBTASN1_LIBRARIES LIBTASN1_INCLUDE_DIR) | ||
|
||
# show the LIBTASN1_INCLUDE_DIR and LIBTASN1_LIBRARIES variables only in the advanced view | ||
mark_as_advanced(LIBTASN1_INCLUDE_DIR LIBTASN1_LIBRARIES) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
include_directories(${GNUTLS_INCLUDE_DIR}) | ||
include_directories(${LIBTASN1_INCLUDE_DIR}) | ||
|
||
add_executable(parsemscat | ||
parsemscat.c) | ||
|
||
target_link_libraries(parsemscat | ||
${GNUTLS_LIBRARIES} | ||
${LIBTASN1_LIBRARIES}) | ||
|
||
configure_file(mscat.asn ${CMAKE_CURRENT_BINARY_DIR}/mscat.asn COPYONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
-- | ||
-- ASN.1 Description for Microsoft Catalog Files | ||
-- | ||
-- Copyright 2016 Andreas Schneider <asn@samba.org> | ||
-- Copyright 2016 Nikos Mavrogiannopoulos <nmav@redhat.com> | ||
-- | ||
CATALOG {} | ||
DEFINITIONS IMPLICIT TAGS ::= -- assuming implicit tags, should try explicit too | ||
|
||
BEGIN | ||
|
||
SpcSerializedObject ::= SEQUENCE { | ||
classID OCTET STRING, | ||
data OCTET STRING | ||
} | ||
|
||
SpcString ::= CHOICE { | ||
unicode [0] IMPLICIT BMPString, | ||
ascii [1] IMPLICIT IA5String | ||
} | ||
|
||
SpcLink ::= CHOICE { --tags may not be accurate | ||
url [0] IA5String, | ||
moniker [1] SpcSerializedObject, | ||
file [2] SpcString | ||
} | ||
|
||
-- CATALOG_NAME_VALUE | ||
CatalogNameValue ::= SEQUENCE { -- 180 | ||
name BMPString, | ||
flags INTEGER, -- 10010001 | ||
value OCTET STRING -- UTF-16-LE | ||
} | ||
|
||
-- CATALOG_MEMBER_INFO | ||
CatalogMemberInfo ::= SEQUENCE { | ||
name BMPString, | ||
id INTEGER -- 0200 | ||
} | ||
|
||
SpcImageDataFile ::= SEQUENCE { -- 458 | ||
flags BIT STRING, | ||
file SpcLink | ||
} | ||
|
||
AlgorithmIdentifier ::= SEQUENCE { -- 500 | ||
algorithm OBJECT IDENTIFIER, | ||
parameters [0] ANY DEFINED BY algorithm OPTIONAL | ||
} | ||
|
||
DigestInfo ::= SEQUENCE { --struct498 | ||
digestAlgorithm AlgorithmIdentifier, | ||
digest OCTET STRING | ||
} | ||
|
||
-- SPC_INDIRECT_DATA | ||
SpcAttributeTypeAndOptionalValue ::= AlgorithmIdentifier | ||
|
||
SpcIndirectDataContent ::= SEQUENCE { | ||
data SpcAttributeTypeAndOptionalValue, | ||
messageDigest DigestInfo | ||
} | ||
|
||
-- SPC_PE_IMAGE_DATA | ||
SpcPeImageFlags ::= BIT STRING { | ||
includeResources (0), | ||
includeDebugInfo (1), | ||
includeImportAddressTable (2) | ||
} | ||
|
||
SpcPeImageData ::= SEQUENCE { | ||
flags SpcPeImageFlags DEFAULT includeResources, | ||
file SpcLink | ||
} | ||
|
||
----------------------------------------------------------- | ||
-- CERT_TRUST_LIST STRUCTURE | ||
----------------------------------------------------------- | ||
|
||
CatalogListId ::= SEQUENCE { | ||
oid OBJECT IDENTIFIER | ||
} | ||
|
||
CatalogListMemberId ::= SEQUENCE { | ||
oid OBJECT IDENTIFIER, | ||
optional NULL | ||
} | ||
|
||
MemberAttribute ::= SEQUENCE { | ||
oid OBJECT IDENTIFIER, | ||
content SET OF ANY | ||
} | ||
|
||
CatalogListMember ::= SEQUENCE { | ||
data OCTET STRING, | ||
attributes SET OF MemberAttribute OPTIONAL | ||
} | ||
|
||
CatalogAttribute ::= SEQUENCE { | ||
oid OBJECT IDENTIFIER, | ||
encapsulated_data OCTET STRING -- encapsulates CatNameValue or SpcPeImageData | ||
} | ||
|
||
CertTrustList ::= SEQUENCE { | ||
catalogListId CatalogListId, | ||
unkownString OCTET STRING, -- 16 bytes MD5 hash? | ||
trustUtcTime UTCTime, | ||
catalogListMemberId CatalogListMemberId, | ||
members SEQUENCE OF CatalogListMember, | ||
attributes [0] EXPLICIT SEQUENCE OF CatalogAttribute OPTIONAL | ||
} | ||
|
||
END |
Oops, something went wrong.