Compare commits

...

117 Commits

Author SHA1 Message Date
Michael Schwarz c60d292b27 Merge pull request #73 from IdeasOnCanvas/enhancement/relaxDateParsing
Relax date parsing
2020-10-16 11:45:57 +02:00
Hannes Oud 4452349d49 Use date for unofficial receipt parts 2020-10-09 11:53:02 +02:00
Hannes Oud d726caa79d Add support for sub-second (ms) dates in receipts as fallback
based on https://github.com/IdeasOnCanvas/AppReceiptValidator/issues/72
2020-10-09 11:52:52 +02:00
Thomas Zoechling 0ea2eb8900 Merge pull request #67 from IdeasOnCanvas/enhancement/redundantResultIgnore
Prepare for new Xcode version
2020-07-28 16:29:27 +02:00
Thomas Zoechling f8d69b3aed Remove redundant underscores - ignoring void return values triggers a warning in new Xcode versions 2020-07-28 15:13:03 +02:00
Michael Schwarz 98f4ccbce8 Update Xcode project settings as recommended 2020-03-05 10:59:25 +01:00
Hannes Oud d57c87e69d Merge pull request #60 from ianbytchek/patch-1
Remove redundant print statement
2019-11-04 10:58:08 +01:00
Ian Bytchek c3eef703ab Remove redundant print statement
Fixes #59.
2019-11-02 18:10:05 +00:00
Michael Schwarz 538302d69c Merge pull request #58 from IdeasOnCanvas/enhancement/localMacAddressDemo
Add local MAC Address to macOS Demo App
2019-10-17 13:55:12 +02:00
Hannes Oud 9c87bd3f71 Improve naming 2019-10-15 11:53:48 +02:00
Hannes Oud 3d7fe8e045 Display local MAC Address in mac demo app 2019-10-15 11:42:10 +02:00
Hannes Oud f2fbd4227a Show local device identifier 2019-10-15 11:25:58 +02:00
Hannes Oud 86ee3389bb Touch storyboard 2019-10-15 11:03:58 +02:00
Michael Schwarz 29f22e4c7d Merge pull request #56 from IdeasOnCanvas/enhancement/dynamicData
Add dynamic data retriever as Receipt Origin
2019-08-27 17:03:25 +02:00
Hannes Oud 6f15dda97a Remove unnecacessary swiftlint disabling 2019-08-27 17:00:02 +02:00
Hannes Oud f7c3e26500 Add dynamic ReceiptOrigin, useful for tests 2019-08-27 16:59:29 +02:00
Hannes Oud 61794a63e3 Fix swift 5.0 badge in readme 2019-05-31 15:10:24 +02:00
Hannes Oud 137a767294 Merge pull request #53 from IdeasOnCanvas/enhancement/intParsingAndDescriptions
Fix quantity and webOrderLineItemID parsing, update for Xcode 10.2, improve convenience
2019-05-31 13:29:13 +02:00
Hannes Oud 11b8faf96c Fix swiftlint warnings 2019-05-31 13:28:24 +02:00
Hannes Oud ee521f9429 Switch to Int64 for ASN1 integer fields, as webOrderLineItemID requires this
# Conflicts:
#	AppReceiptValidator/AppReceiptValidator/OpenSSL/ASN1Helpers.swift
#	AppReceiptValidator/AppReceiptValidator/Receipt.swift
2019-05-31 13:18:57 +02:00
Hannes Oud bf7010545b Update readme for Swift 5.0 2019-05-31 10:32:28 +02:00
Hannes Oud 6a1b919093 Update travis file for Xcode 10.2 2019-05-31 10:29:51 +02:00
Hannes Oud e8146f7122 Disable an unnecessary swiftlint warning 2019-05-23 17:28:30 +02:00
Hannes Oud 2f54c5b042 Update macOS project for Xcode 10.2 / Swift 5 2019-05-23 17:26:16 +02:00
Hannes Oud f0ba73b45e Modernize Data initializer to fix deprectation warning 2019-05-23 17:25:56 +02:00
Hannes Oud 0ff100054d Add Stringy convenience initializers to Receipt and InAppPurchaseReceipt 2019-05-23 17:25:21 +02:00
Hannes Oud 15e3bb5471 Fix test-data after fixing quantity and webOrderLineItemId parsing 2019-05-23 16:47:03 +02:00
Hannes Oud c42f8d9ac9 Fix deprecation warnings using data.withUnsafeBytes 2019-05-23 14:32:07 +02:00
Hannes Oud 0efe3dd839 Update for Xcode 10.2, Swift 5 2019-05-23 14:31:47 +02:00
Hannes Oud cb4690217b Add quotes around strings and dates when creating description 2019-05-23 14:15:23 +02:00
Hannes Oud 8266af7edb Assert octet string when unwrapping and add comments 2019-05-23 14:15:06 +02:00
Hannes Oud 51d190ece0 Unwrap int values correctly (quantity, web order line item) 2019-05-23 14:14:45 +02:00
Hannes Oud 26385ee11b Merge pull request #52 from lightsprint09/extension-save
Support App extensions
2019-03-26 10:32:04 +01:00
Lukas Schmidt a96f16969d support app extensions to silence warning when use in a extension 2019-03-10 12:54:43 +01:00
Hannes Oud 1ba0b31095 Merge pull request #51 from IdeasOnCanvas/enhancement/deviceIdentifierFromMacAddress
Support DeviceIdentifier from MAC Address String
2018-11-22 16:11:06 +01:00
Hannes Oud 5121e901f5 Remove unneeded prefix 2018-11-22 16:10:44 +01:00
Hannes Oud d31ab05fe2 Update gif 2018-11-22 12:29:06 +01:00
Hannes Oud c4769bc42a Update mac demo app to support identifiers 2018-11-22 12:22:58 +01:00
Hannes Oud 6605544598 Add tests for DeviceIdentifier 2018-11-22 11:54:19 +01:00
Hannes Oud 3bb92db368 Add DeviceIdentifier initializer with macAddress string 2018-11-22 11:48:28 +01:00
Hannes Oud 97b0adff0a Make primary mac address function internal (testable) 2018-11-22 11:48:13 +01:00
Hannes Oud bf875864ea Fix typo 2018-11-22 11:47:50 +01:00
Hannes Oud c536866906 Merge pull request #50 from IdeasOnCanvas/chore/Xcode10
Update to Xcode 10 and Swift 4.2
2018-09-24 17:20:23 +02:00
Hannes Oud ede64d2e3b Update Swift version in Readme 2018-09-24 16:10:10 +02:00
Hannes Oud 112a5a9e4f Update travis.yml for Xcode 10 and iOS 12 2018-09-24 16:09:19 +02:00
Hannes Oud 7d8cb7bd06 Update schemes, parrallelize tests and make execution order random 2018-09-24 16:06:41 +02:00
Hannes Oud da06a099ce Make tests unhosted 2018-09-24 16:04:18 +02:00
Hannes Oud 95337f7544 Upgrade to Swift 4.2 and Xcode 10 2018-09-24 16:00:56 +02:00
Hannes Oud 7ee443a4af Merge pull request #49 from IdeasOnCanvas/chore/core/moveSwiftlintFromFrameworkTarget
Move Swiftlint run script phases to example project
2018-07-05 11:03:21 +02:00
Hannes Oud ae082be181 Remove placeholder comment from script phase 2018-07-05 11:01:48 +02:00
Hannes Oud bcb0ee2c27 Move Swiftlint run script phases to example project 2018-07-03 15:23:48 +02:00
Hannes Oud f8dae53736 Merge pull request #48 from IdeasOnCanvas/enhancement/modernizeForSwift41
Remove Sourcery and update README with new references
2018-04-24 11:43:57 +02:00
Hannes Oud 5c90e58864 Update README, add links to AppStoreReceiptChecker 2018-04-16 18:22:13 +02:00
Hannes Oud df47710990 Remove sourcery from README 2018-04-16 18:12:30 +02:00
Hannes Oud 9b03d4b850 Remove sourcery from .swiftlint.yml 2018-04-16 18:08:42 +02:00
Hannes Oud 06b43589d6 Use two char indentation in swiftlint run phase, add SRCROOT as input to prepare for new build system 2018-04-16 18:06:23 +02:00
Hannes Oud 1722f04928 Remove vertical whitespaces 2018-04-16 18:06:23 +02:00
Hannes Oud 16ef7de4bf Remove Sourcery 2018-04-16 17:42:45 +02:00
Hannes Oud 7521a419d1 Upgrade swift badge in readme 2018-04-03 10:54:39 +02:00
Hannes Oud 5f0ad3de3f Merge pull request #46 from arturgrigor/master
Xcode 9.3 support and fixed the SwiftLint issue
2018-04-03 10:41:46 +02:00
Artur Grigor 40eeef07a5 Xcode 9.3 support and fixed the SwiftLint issue. 2018-04-02 14:39:19 +03:00
Hannes Oud 11563b5094 Remove simulator list printing 2018-02-15 15:22:24 +01:00
Hannes Oud 35815fcd7c Disable code signing and mac app sandbox 2018-02-15 15:21:33 +01:00
Hannes Oud 17c598d414 Fix xcrun typo in .travis.yml 2018-02-15 14:53:57 +01:00
Hannes Oud cff64329b3 Update .travis.yml indention, output simulators and variables 2018-02-15 14:15:10 +01:00
Hannes Oud 9ba44a9a15 Merge pull request #41 from IdeasOnCanvas/feature/macOS/dragNDropFiles
Allow drag & drop of applications and receipt files on mac
2018-02-14 11:32:59 +01:00
Hannes Oud 5c9d107b0c Add a newline 2018-02-14 11:32:41 +01:00
Hannes Oud 3a5ced4184 Merge pull request #43 from IdeasOnCanvas/enhancement/core/updateOpenSSL
Update Open-SSL to 1.0.2n
2018-02-14 11:30:58 +01:00
Markus Müller-Simhofer e2f0cb0a92 Merge pull request #42 from IdeasOnCanvas/enhancement/core/ci
Add .travis.yml
2018-02-14 11:15:44 +01:00
Markus Müller-Simhofer 75a9f76523 Testing Travis 2018-02-14 10:57:15 +01:00
Markus Müller-Simhofer db9c32529b Update .travis.yml 2018-02-14 10:53:44 +01:00
Markus Müller-Simhofer 064fe09bc9 Try to trigger Travis 2018-02-14 10:50:44 +01:00
Hannes Oud 5d872a9fec Add travis build status badge 2018-02-13 16:48:26 +01:00
Hannes Oud b0190be957 Update Root Certificate info in readme 2018-02-13 16:43:23 +01:00
Hannes Oud 92ca444675 Update Readme with better OpenSSL instructions 2018-02-13 16:30:35 +01:00
Hannes Oud cc431c6205 Adapt open-ssl headers for submodule 2018-02-13 16:23:54 +01:00
Hannes Oud 84791b8679 Update with fresh built openssl 1.0.2n 2018-02-13 16:12:40 +01:00
Hannes Oud 89796e1ad1 Add .travis.yml 2018-02-13 16:00:04 +01:00
Hannes Oud 1f7835f417 Update readme and add gif 2018-02-13 15:17:52 +01:00
Hannes Oud e577f8b637 Allow drag & drop of applications and receipt files on mac left text input view in demo app 2018-02-13 14:53:54 +01:00
Michael Schwarz d0ff482635 Merge pull request #39 from IdeasOnCanvas/feature/core/improveSignatureParameter
Merge two related properties to an enum
2018-02-13 14:00:19 +01:00
Hannes Oud efbe0322ae Update Readme 2018-02-09 11:53:24 +01:00
Hannes Oud 2ae1233aa1 Merge two related properties to an enum 2018-02-09 11:49:36 +01:00
Hannes Oud a35fec85d0 Merge pull request #38 from IdeasOnCanvas/enhancement/core/grandRename
Rename Hekate & LocalReceiptValidator to AppReceiptValidator
2018-02-09 11:11:10 +01:00
Hannes Oud 343f435bf6 Run sourcery 2018-02-08 16:23:38 +01:00
Hannes Oud 72e1306a26 Rename more occurrences of LocalReceiptValidator to AppReceiptValidator 2018-02-08 16:17:46 +01:00
Hannes Oud 15e9264581 Update Readme by removing Hekate and adding Credits 2018-02-08 16:11:50 +01:00
Hannes Oud f6bbc9dfa5 Rename remaining instances of Hekate in file contents 2018-02-08 16:06:46 +01:00
Hannes Oud bfb77a3bdd Rename root folder 2018-02-08 16:04:14 +01:00
Hannes Oud 3d3548d523 Rename schemes 2018-02-08 16:01:25 +01:00
Hannes Oud 80f80c5cb4 Rename code comments and sort imports 2018-02-08 16:00:08 +01:00
Hannes Oud ec467faa75 Rename module, fix scheme, project and entitlements, touch storyboards 2018-02-08 15:59:43 +01:00
Hannes Oud 57c53573b8 Rename folders and files 2018-02-08 15:53:53 +01:00
Hannes Oud 3f5d730c65 Rename Info plist contents and product bundle identifiers 2018-02-08 15:52:05 +01:00
Hannes Oud a2ce0c56c3 Rename Project 2018-02-08 15:49:49 +01:00
Hannes Oud 93694a77ef Add link to license badge 2018-01-23 14:03:38 +01:00
Hannes Oud b9a65b4b6d Fix typo and update readme 2018-01-23 14:00:19 +01:00
Hannes Oud e99bef59e0 Update readme 2018-01-23 12:23:44 +01:00
Hannes Oud bf86bb9ce4 Add LICENSE 2018-01-23 11:14:24 +01:00
Hannes Oud 25b8a50d92 Fix swiftlint warnings 2018-01-12 15:30:53 +01:00
Hannes Oud 44df2e4271 Update .swiftlint.yml 2018-01-12 15:30:41 +01:00
Hannes Oud 4bf518cd21 Merge pull request #34 from IdeasOnCanvas/core/feature/inofficialAttributes
Parse Unofficial Receipt attributes
2018-01-09 11:19:10 +01:00
Hannes Oud be46b25247 Deactivate autocorrect etc in iOS text view 2018-01-08 13:50:04 +01:00
Hannes Oud 2519fdfb23 Apply changes from code review 2018-01-08 13:47:48 +01:00
Hannes Oud 2f1ba126e7 Add KnownOrUnknown and use for provisioningType 2018-01-08 11:30:36 +01:00
Hannes Oud 8e9c94bb88 Improve attribute parsing and description 2017-12-15 19:38:28 +01:00
Hannes Oud ecee35a2e9 WIP Parse unofficial receipts attributes and log in mac app 2017-12-15 17:38:06 +01:00
Hannes Oud 9ef265073b Implement iOS demo app 2017-12-15 16:27:12 +01:00
Hannes Oud 3e69affe7e Implement mac demo app 2017-12-15 16:24:45 +01:00
Hannes Oud 3702ec3648 Fix Swiftlint warnings 2017-11-30 12:38:58 +01:00
Matthias Tretter eb78f3f493 Merge pull request #29 from IdeasOnCanvas/core/enhancement/improveInitialization
Rename allSteps to default, add a full initializer as well
2017-11-30 12:32:01 +01:00
Matthias Tretter 7477d83d4c Merge pull request #32 from IdeasOnCanvas/core/enhancement/removeUnusedFunctionality
Remove demo view model and view controller and receiptrefresher
2017-11-30 12:29:48 +01:00
Hannes Oud 5393889f39 Remove demo view model and view controller and receiptrefresher, as not usable for much 2017-11-30 12:19:17 +01:00
Hannes Oud be99440c4a Update readme 2017-11-27 10:15:09 +01:00
Hannes Oud bfa0c279cc Remove validateReceipt(configuration:) and add to tests as convenience instead 2017-11-24 16:33:50 +01:00
Hannes Oud 15144274a9 Rename allSteps to default, add a full initializer as well 2017-11-24 16:21:47 +01:00
Hannes Oud 3928822cbb Remove a unnecessary break 2017-11-24 16:13:15 +01:00
227 changed files with 5332 additions and 1328 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
Hekate/Hekate/OpenSSL/include-ios/* linguist-vendored
Hekate/Hekate/OpenSSL/include-macos/* linguist-vendored
AppReceiptValidator/AppReceiptValidator/OpenSSL/include-ios/* linguist-vendored
AppReceiptValidator/AppReceiptValidator/OpenSSL/include-macos/* linguist-vendored
+18
View File
@@ -0,0 +1,18 @@
language: objective-c
osx_image: xcode10.2
env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
- PROJECT=AppReceiptValidator/AppReceiptValidator.xcodeproj
matrix:
- DESTINATION="OS=12.2,name=iPhone X" SCHEME="AppReceiptValidator Demo iOS"
- DESTINATION="arch=x86_64" SCHEME="AppReceiptValidator Demo macOS"
script:
- set -o pipefail
- xcodebuild -version
- xcodebuild -showsdks
- echo "PROJECT $PROJECT, SCHEME $SCHEME, DESTINATION $DESTINATION"
- xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
@@ -4,7 +4,7 @@ disabled_rules:
- nesting
- todo
excluded:
- Sourcery/Generated
- excluded_dir_example
file_length:
warning: 500
large_tuple:
@@ -12,10 +12,10 @@ large_tuple:
warning: 3
opt_in_rules:
- empty_count
- overridden_super_call
- explicit_init
- closure_spacing
- operator_usage_whitespace
- overridden_super_call
- prohibited_super_call
- nimble_operator
- redundant_nil_coalescing
@@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
}
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13189.4" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13165.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -14,11 +11,11 @@
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hekate" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zp8-aJ-GRo">
<rect key="frame" x="160" y="333" width="55" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AppReceiptValidator" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zp8-aJ-GRo">
<rect key="frame" x="221.5" y="299" width="156" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="Stack View standard spacing" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="AppReceiptValidator_Demo_iOS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" layoutMarginsFollowReadableWidth="YES" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="ZPu-bH-r6v">
<rect key="frame" x="15" y="40" width="345" height="627"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hUb-y9-69b">
<rect key="frame" x="0.0" y="0.0" width="345" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Base64" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Pt-dr-EUg">
<rect key="frame" x="0.0" y="0.0" width="309" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" horizontalCompressionResistancePriority="749" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kT0-fB-cXz">
<rect key="frame" x="309" y="0.0" width="36" height="30"/>
<state key="normal" title="Clear"/>
<connections>
<action selector="clear" destination="BYZ-38-t0r" eventType="touchUpInside" id="xOC-lG-aMe"/>
</connections>
</button>
</subviews>
</stackView>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="g3x-aA-9dO">
<rect key="frame" x="0.0" y="38" width="345" height="167"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" smartDashesType="no" smartInsertDeleteType="no" smartQuotesType="no"/>
</textView>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="czZ-e2-zE0">
<rect key="frame" x="0.0" y="213" width="345" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Receipt" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vyX-F8-RGT">
<rect key="frame" x="0.0" y="0.0" width="309" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" horizontalCompressionResistancePriority="749" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TDa-xH-OJJ">
<rect key="frame" x="309" y="0.0" width="36" height="30"/>
<state key="normal" title="Copy"/>
<connections>
<action selector="copyOutput" destination="BYZ-38-t0r" eventType="touchUpInside" id="cO0-6s-2Ul"/>
</connections>
</button>
</subviews>
</stackView>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="250" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="Wjc-3l-w1w">
<rect key="frame" x="0.0" y="251" width="345" height="376"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" smartDashesType="no" smartInsertDeleteType="no" smartQuotesType="no"/>
</textView>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<constraints>
<constraint firstItem="ZPu-bH-r6v" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="topMargin" id="O9X-Jq-xyq"/>
<constraint firstItem="ZPu-bH-r6v" firstAttribute="bottom" secondItem="MPn-6g-0qv" secondAttribute="bottom" id="VFh-St-0bL"/>
<constraint firstItem="g3x-aA-9dO" firstAttribute="height" secondItem="8bC-Xf-vdC" secondAttribute="height" multiplier="1:4" id="hbr-Fh-GQs"/>
<constraint firstItem="ZPu-bH-r6v" firstAttribute="leading" secondItem="MPn-6g-0qv" secondAttribute="leading" constant="15" id="iaR-gF-ocn"/>
<constraint firstItem="ZPu-bH-r6v" firstAttribute="trailing" secondItem="MPn-6g-0qv" secondAttribute="trailing" constant="-15" id="rHb-Bb-pZ9"/>
</constraints>
<edgeInsets key="layoutMargins" top="20" left="20" bottom="20" right="20"/>
<viewLayoutGuide key="safeArea" id="MPn-6g-0qv"/>
</view>
<connections>
<outlet property="inputTextView" destination="g3x-aA-9dO" id="HAQ-V9-HfJ"/>
<outlet property="outputTextView" destination="Wjc-3l-w1w" id="ZdS-SB-fPa"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="140" y="132.68365817091455"/>
</scene>
</scenes>
</document>
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Hekate Demo</string>
<string>AppReceiptValidator Demo</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -0,0 +1,97 @@
//
// ViewController.swift
// Demo iOS
//
// Created by Hannes Oud on 04.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import AppReceiptValidator
import UIKit
/// Displays two textfields. One to paste a receipt into as base64 string, the other displaying the parsed receipt.
/// A device identifier for validation is not supported, have a look at the mac demo instead.
class ViewController: UIViewController, UITextViewDelegate {
@IBOutlet private var inputTextView: UITextView!
@IBOutlet private var outputTextView: UITextView!
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.inputTextView.delegate = self
self.inputTextView.text = ""
self.outputTextView.text = "Parsed Receipt will be shown here"
NotificationCenter.default.addObserver(self, selector: #selector(triggerAutoPaste), name: UIApplication.willEnterForegroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(triggerAutoPaste), name: UIPasteboard.changedNotification, object: nil)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if self.autoPaste() {
return
} else {
self.inputTextView.becomeFirstResponder()
}
}
// MARK: - UITextViewDelegate
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
DispatchQueue.main.async {
self.update(base64String: self.inputTextView.text)
}
return true
}
}
// MARK: - Private
private extension ViewController {
// MARK: Actions
@objc
func triggerAutoPaste() {
self.autoPaste()
}
@IBAction func clear() {
self.inputTextView.text = ""
}
@IBAction func copyOutput() {
UIPasteboard.general.string = self.outputTextView.text
}
// MARK: Updating
/// pastes from clipboard if it is base64 decodable
@discardableResult
func autoPaste() -> Bool {
guard let string = UIPasteboard.general.string,
Data(base64Encoded: string, options: .ignoreUnknownCharacters) != nil else { return false }
self.inputTextView.text = string
self.update(base64String: string)
return true
}
func update(base64String: String) {
guard let data = Data(base64Encoded: base64String, options: .ignoreUnknownCharacters) else {
self.render(string: "Base64 decoding failed.")
return
}
do {
let result = try AppReceiptValidator().parseUnofficialReceipt(origin: .data(data))
render(string: "\(result.receipt)\n\(result.unofficialReceipt)")
} catch {
self.render(string: "\(error)")
}
}
func render(string: String) {
self.outputTextView.text = string
}
}
@@ -1,6 +1,6 @@
//
// AppDelegate.swift
// Hekate Demo macOS
// AppReceiptValidator Demo macOS
//
// Created by Hannes Oud on 06.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="15400" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15400"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Application-->
@@ -10,11 +12,11 @@
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="Hekate Demo macOS" id="1Xt-HY-uBw">
<menuItem title="AppReceiptValidator Demo macOS" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Hekate Demo macOS" systemMenu="apple" id="uQy-DD-JDr">
<menu key="submenu" title="AppReceiptValidator Demo macOS" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About Hekate Demo macOS" id="5kV-Vb-QxS">
<menuItem title="About AppReceiptValidator Demo macOS" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
@@ -28,7 +30,7 @@
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide Hekate Demo macOS" keyEquivalent="h" id="Olw-nP-bQN">
<menuItem title="Hide AppReceiptValidator Demo macOS" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
</connections>
@@ -46,7 +48,7 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit Hekate Demo macOS" keyEquivalent="q" id="4sb-4s-VLi">
<menuItem title="Quit AppReceiptValidator Demo macOS" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
</connections>
@@ -618,7 +620,7 @@
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
</connections>
</menuItem>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
@@ -659,7 +661,7 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
<menuItem title="Hekate Demo macOS Help" keyEquivalent="?" id="FKE-Sm-Kum">
<menuItem title="AppReceiptValidator Demo macOS Help" keyEquivalent="?" id="FKE-Sm-Kum">
<connections>
<action selector="showHelp:" target="Ady-hI-5gd" id="y7X-2Q-9no"/>
</connections>
@@ -673,7 +675,7 @@
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="target"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="AppReceiptValidator_Demo_macOS" customModuleProvider="target"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
@@ -683,12 +685,12 @@
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<window key="window" title="AppReceiptValidator Receipt Parser" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<connections>
<connections>
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
</connections>
</window>
@@ -703,15 +705,165 @@
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="AppReceiptValidator_Demo_macOS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" wantsLayer="YES" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<rect key="frame" x="0.0" y="0.0" width="698" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ynK-dw-fFc">
<rect key="frame" x="0.0" y="71" width="349" height="199"/>
<clipView key="contentView" drawsBackground="NO" id="yEL-yO-YvB">
<rect key="frame" x="1" y="1" width="347" height="197"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView toolTip="Paste Base64 here" importsGraphics="NO" richText="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" textCompletion="NO" id="0xW-mT-lME" customClass="DropAcceptingTextView" customModule="AppReceiptValidator_Demo_macOS" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="347" height="197"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="347" height="197"/>
<size key="maxSize" width="629" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="TaD-v9-pOg">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="hkR-e4-WtN">
<rect key="frame" x="332" y="1" width="16" height="197"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<scrollView toolTip="Parsed Receipt will be shown here" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6mt-ay-mAL">
<rect key="frame" x="349" y="0.0" width="349" height="270"/>
<clipView key="contentView" drawsBackground="NO" id="YwZ-F9-Cvh">
<rect key="frame" x="1" y="1" width="347" height="268"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" textCompletion="NO" id="GHT-gS-G1g" customClass="TextView" customModule="AppReceiptValidator_Demo_macOS" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="347" height="268"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="347" height="268"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="xmd-vm-w1P">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="uk9-Sg-RUp">
<rect key="frame" x="332" y="1" width="16" height="268"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="X6E-h2-FTp">
<rect key="frame" x="0.0" y="0.0" width="349" height="71"/>
<subviews>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yvX-By-nNw">
<rect key="frame" x="0.0" y="50" width="316" height="21"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="Optional DeviceIdentifier for Validation (MAC Address, UUID, Base64)" drawsBackground="YES" id="Z2r-sB-vIS">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="identifierDidChange:" target="XfG-lQ-9wD" id="ccM-mH-NPQ"/>
</connections>
</textField>
<customView verticalHuggingPriority="251" verticalCompressionResistancePriority="749" translatesAutoresizingMaskIntoConstraints="NO" id="MIY-2Q-BBh">
<rect key="frame" x="0.0" y="0.0" width="276" height="50"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="top" spacing="14" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Fk-0l-MkU">
<rect key="frame" x="5" y="2" width="264" height="48"/>
<subviews>
<textField horizontalHuggingPriority="252" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3HO-XF-hNE">
<rect key="frame" x="-2" y="32" width="122" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Local MAC Address" id="cII-wV-fEg">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MYU-Qf-vgG">
<rect key="frame" x="130" y="32" width="37" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" title="Label" id="toH-92-xds">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7M8-eM-sps">
<rect key="frame" x="173" y="20" width="97" height="32"/>
<buttonCell key="cell" type="push" title="Reload" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="nhJ-Nu-6Mt">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="determineDeviceIdentifier:" target="XfG-lQ-9wD" id="0Iu-Ou-tt2"/>
</connections>
</button>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstItem="3Fk-0l-MkU" firstAttribute="top" secondItem="MIY-2Q-BBh" secondAttribute="top" id="G9h-eg-R7c"/>
<constraint firstItem="3Fk-0l-MkU" firstAttribute="leading" secondItem="MIY-2Q-BBh" secondAttribute="leading" constant="5" id="XhE-X8-Yll"/>
<constraint firstAttribute="bottom" secondItem="3Fk-0l-MkU" secondAttribute="bottom" constant="2" id="eS8-I6-F8I"/>
<constraint firstAttribute="trailing" secondItem="3Fk-0l-MkU" secondAttribute="trailing" constant="7" id="u5d-kZ-Hiq"/>
</constraints>
</customView>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstItem="X6E-h2-FTp" firstAttribute="top" secondItem="ynK-dw-fFc" secondAttribute="bottom" id="0st-m4-dJZ"/>
<constraint firstItem="ynK-dw-fFc" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" id="1Pf-3A-rBH"/>
<constraint firstAttribute="bottom" secondItem="X6E-h2-FTp" secondAttribute="bottom" id="1kz-OO-S1i"/>
<constraint firstItem="6mt-ay-mAL" firstAttribute="leading" secondItem="X6E-h2-FTp" secondAttribute="trailing" id="9Vb-5X-3ef"/>
<constraint firstItem="ynK-dw-fFc" firstAttribute="leading" secondItem="m2S-Jp-Qdl" secondAttribute="leading" id="Cvz-FD-lzg"/>
<constraint firstItem="6mt-ay-mAL" firstAttribute="width" secondItem="m2S-Jp-Qdl" secondAttribute="width" multiplier="1:2" id="SWu-Yn-pVc"/>
<constraint firstAttribute="trailing" secondItem="6mt-ay-mAL" secondAttribute="trailing" id="Yun-Rd-wsm"/>
<constraint firstItem="6mt-ay-mAL" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" id="clC-xc-JDh"/>
<constraint firstAttribute="bottom" secondItem="6mt-ay-mAL" secondAttribute="bottom" id="lKc-RV-ybx"/>
<constraint firstItem="ynK-dw-fFc" firstAttribute="width" secondItem="m2S-Jp-Qdl" secondAttribute="width" multiplier="1:2" id="wsI-iB-DvJ"/>
<constraint firstItem="X6E-h2-FTp" firstAttribute="leading" secondItem="m2S-Jp-Qdl" secondAttribute="leading" id="ysr-U6-n9c"/>
</constraints>
</view>
<connections>
<outlet property="dropReceivingView" destination="0xW-mT-lME" id="cuR-H1-BKN"/>
<outlet property="identifierTextField" destination="yvX-By-nNw" id="pW5-lJ-8Cy"/>
<outlet property="inputTextView" destination="0xW-mT-lME" id="8Y7-yb-63r"/>
<outlet property="localDeviceIdentifierLabel" destination="MYU-Qf-vgG" id="cqz-uf-16l"/>
<outlet property="outputTextView" destination="GHT-gS-G1g" id="cVN-4m-knJ"/>
</connections>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="655"/>
<point key="canvasLocation" x="75" y="726"/>
</scene>
</scenes>
</document>
@@ -0,0 +1,56 @@
//
// DropAcceptingTextView.swift
// AppReceiptValidator Demo macOS
//
// Created by Hannes Oud on 13.02.18.
// Copyright © 2018 IdeasOnCanvas GmbH. All rights reserved.
//
import Cocoa
private enum AttachmentDropError: Error {
case noAttachments
}
final class DropAcceptingTextView: NSTextView {
var handleDroppedFile: ((URL) -> Void)?
override func awakeFromNib() {
super.awakeFromNib()
var draggedTypes = self.registeredDraggedTypes
draggedTypes.insert(makeFileNameType(), at: 0)
self.registerForDraggedTypes(draggedTypes)
}
override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
if sender.fileURLs.isEmpty == false {
return .copy
}
return super.draggingEntered(sender)
}
override func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
if let fileURL = sender.fileURLs.first {
self.handleDroppedFile?(fileURL)
return true
}
return super.performDragOperation(sender)
}
}
fileprivate extension NSDraggingInfo {
var fileURLs: [URL] {
let asStrings = self.draggingPasteboard.propertyList(forType: makeFileNameType()) as? [String] ?? []
return asStrings.map { URL(fileURLWithPath: $0) }
}
}
private func makeFileNameType() -> NSPasteboard.PasteboardType {
// in 10.13 there is more modern NSPasteboard.PasteboardType.fileURL or previously
// NSPasteboard.PasteboardType("public.file-url"), but so far couldn't find a way
// to read them from draggingPasteboard()
return NSPasteboard.PasteboardType(rawValue: "NSFilenamesPboardType")
}
@@ -0,0 +1,148 @@
//
// ViewController.swift
// AppReceiptValidator Demo macOS
//
// Created by Hannes Oud on 06.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import AppReceiptValidator
import Cocoa
/// Displays two textfields. One to paste a receipt into as base64 string, the other displaying the parsed receipt.
/// A device identifier can be added in a third field, which is then used to validate the receipt.
class ViewController: NSViewController, NSTextViewDelegate, NSTextFieldDelegate {
private var textFieldObserver: Any?
@IBOutlet private var inputTextView: NSTextView!
@IBOutlet private var identifierTextField: NSTextField!
@IBOutlet private var outputTextView: NSTextView!
@IBOutlet private var dropReceivingView: DropAcceptingTextView!
@IBOutlet private var localDeviceIdentifierLabel: NSTextField!
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.inputTextView.delegate = self
self.inputTextView.string = "Drag Application or receipt here, or paste Base64 receipt contents."
self.outputTextView.string = "Parsed Receipt will be shown here"
self.dropReceivingView.handleDroppedFile = { [unowned self] url in
self.update(url: url)
}
self.textFieldObserver = NotificationCenter.default.addObserver(forName: NSTextField.textDidChangeNotification, object: self.identifierTextField, queue: .main) { [weak self] _ in
guard let self = self else { return }
self.identifierDidChange(self.identifierTextField)
}
self.renderLocalDeviceIdentifierText()
}
// MARK: - NSTextViewDelegate
func textDidChange(_ notification: Notification) {
let string = self.inputTextView.string
self.update(base64String: string)
}
// MARK: - Identifier Textfield
@IBAction func identifierDidChange(_ sender: NSTextField) {
let string = self.inputTextView.string
self.update(base64String: string)
}
// MARK: - Actions
func paste(_ sender: Any) {
self.inputTextView.paste(sender)
}
@IBAction func determineDeviceIdentifier(_ sender: Any) {
self.renderLocalDeviceIdentifierText()
}
}
// MARK: - Private
private extension ViewController {
// MARK: Updating
func update(base64String: String) {
guard let data = Data(base64Encoded: base64String, options: .ignoreUnknownCharacters) else {
self.render(string: "Base64 decoding failed.")
return
}
do {
let result = try AppReceiptValidator().parseUnofficialReceipt(origin: .data(data))
let validationResult = self.validateReceiptIfNecessary(data: data, macAddress: self.identifierTextField.stringValue) ?? "<Receipt not Validated, No Identifier provided, Supported: UUID, base64, MAC-Address>"
self.render(string: "\(validationResult)\n\n✅ Receipt Parsed\n\(result.receipt)\n\(result.unofficialReceipt)")
} catch {
self.render(string: "\(error)")
}
}
func update(url: URL) {
var url = url
let subURLInApplication = url.appendingPathComponent("Contents/_MASReceipt/receipt")
if FileManager.default.fileExists(atPath: subURLInApplication.path) {
url = subURLInApplication
}
if let data = try? Data(contentsOf: url) {
let base64 = data.base64EncodedString()
self.inputTextView.string = base64
self.update(base64String: base64)
} else {
self.inputTextView.string = "<No Receipt found>"
self.update(base64String: "")
}
}
func validateReceiptIfNecessary(data: Data, macAddress: String?) -> String? {
guard let macAddress = macAddress, macAddress.isEmpty == false else { return nil }
let sanitized = macAddress.trimmingCharacters(in: .whitespacesAndNewlines)
let deviceIdentifier = AppReceiptValidator.Parameters.DeviceIdentifier(macAddress: sanitized) ??
(UUID(uuidString: sanitized).flatMap { AppReceiptValidator.Parameters.DeviceIdentifier(uuid: $0) }) ??
AppReceiptValidator.Parameters.DeviceIdentifier(base64Encoded: sanitized)
guard let identifier = deviceIdentifier else { return "<Receipt not Validated\nIdentifier not parseable>" }
let parameters = AppReceiptValidator.Parameters(receiptOrigin: .data(data), shouldValidateSignaturePresence: true, signatureValidation: .shouldValidate(rootCertificateOrigin: .cerFileBundledWithAppReceiptValidator), shouldValidateHash: true, deviceIdentifier: identifier, propertyValidations: [])
let result = AppReceiptValidator().validateReceipt(parameters: parameters)
switch result {
case .success:
return "✅ Receipt Validated\nSignature and Hash Check successful"
case .error(let error, _, _):
return "❌ Receipt Invalid\n\(error)"
}
}
func localDeviceIdentifierString() -> String {
guard let device = AppReceiptValidator.Parameters.DeviceIdentifier.getPrimaryNetworkMACAddress() else { return "DeviceIdentifier could not be determined" }
return "\(device.addressString) (HEX), \(device.data.base64EncodedString()) (B64)"
}
func render(string: String) {
self.outputTextView.string = string
}
func renderLocalDeviceIdentifierText() {
NSLog("Local MAC Address: " + localDeviceIdentifierString())
self.localDeviceIdentifierLabel.attributedStringValue =
NSAttributedString(string: localDeviceIdentifierString())
}
}
// MARK: - TextView
/// TextView that clears contents before pasting
private class TextView: NSTextView {
override func paste(_ sender: Any?) {
self.string = ""
super.paste(sender)
}
}
@@ -1,17 +1,17 @@
//
// LocalReceiptPropertyValidationTests.swift
// Hekate iOS
// AppReceiptPropertyValidationTests.swift
// AppReceiptValidator iOS
//
// Created by Hannes Oud on 14.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import Hekate
import AppReceiptValidator
import XCTest
class LocalReceiptPropertyValidationTests: XCTestCase {
class AppReceiptPropertyValidationTests: XCTestCase {
private let receiptValidator = LocalReceiptValidator()
private let receiptValidator = AppReceiptValidator()
func testCorrectMainBundlePropertiesiOS() {
let receipt = Receipt(bundleIdentifier: Bundle.main.bundleIdentifier,
@@ -78,7 +78,7 @@ class LocalReceiptPropertyValidationTests: XCTestCase {
guard let data = assertTestAsset(filename: "hannes_mac_mindnode_pro_receipt") else { return }
@discardableResult
func assertPropertyMismatch(line: UInt = #line, configuration: (inout LocalReceiptValidator.Parameters) -> Void) -> Bool {
func assertPropertyMismatch(line: UInt = #line, configuration: (inout AppReceiptValidator.Parameters) -> Void) -> Bool {
let result = receiptValidator.validateReceipt {
$0.receiptOrigin = .data(data)
$0.shouldValidateHash = false // the original device identifier is unknown
@@ -89,7 +89,7 @@ class LocalReceiptPropertyValidationTests: XCTestCase {
XCTFail("Unexpectedly succeeded validating, but expected a property mismatch)", file: #file, line: line)
return false
}
guard error == LocalReceiptValidator.Error.propertyValueMismatch else {
guard error == AppReceiptValidator.Error.propertyValueMismatch else {
XCTFail("Expected a property mismatch, but found an \(error)", file: #file, line: line)
return false
}
@@ -1,17 +1,17 @@
//
// LocalReceiptValidationInAppPurchaseTests.swift
// Hekate
// AppReceiptValidationInAppPurchaseTests.swift
// AppReceiptValidator
//
// Created by Hannes Oud on 11.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import Hekate
import AppReceiptValidator
import XCTest
class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
class AppReceiptValidationInAppPurchaseTests: XCTestCase {
var receiptValidator = LocalReceiptValidator()
var receiptValidator = AppReceiptValidator()
func testNonMindNodeReceiptParsingWithoutValidation() {
guard let data = assertB64TestAsset(filename: "grandUnifiedExpiredAppleCert_receipt.b64") else { return }
@@ -22,7 +22,6 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
} catch {
XCTFail("Unexpectedly failed parsing a receipt \(error)")
}
}
func testNonMindNodeReceiptParsingWithMultipleInAppPurchases() {
@@ -33,7 +32,7 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
let result = receiptValidator.validateReceipt {
$0.receiptOrigin = .data(data)
$0.shouldValidateHash = false
$0.shouldValidateSignatureAuthenticity = false
$0.signatureValidation = .skip
$0.propertyValidations = []
}
guard let receipt = result.receipt else {
@@ -55,7 +54,7 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
expirationDate: nil,
inAppPurchaseReceipts: [
InAppPurchaseReceipt(
quantity: nil,
quantity: 1,
productIdentifier: "consumable",
transactionIdentifier: "1000000166865231",
originalTransactionIdentifier: "1000000166865231",
@@ -63,10 +62,10 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
originalPurchaseDate: Date.demoDate(string: "2015-08-07T20:37:55Z"),
subscriptionExpirationDate: nil,
cancellationDate: nil,
webOrderLineItemId: nil
webOrderLineItemId: 0
),
InAppPurchaseReceipt(
quantity: nil,
quantity: 1,
productIdentifier: "monthly",
transactionIdentifier: "1000000166965150",
originalTransactionIdentifier: "1000000166965150",
@@ -74,10 +73,10 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
originalPurchaseDate: Date.demoDate(string: "2015-08-10T06:49:33Z"),
subscriptionExpirationDate: Date.demoDate(string: "2015-08-10T06:54:32Z"),
cancellationDate: nil,
webOrderLineItemId: nil
webOrderLineItemId: 1000000030274153
),
InAppPurchaseReceipt( // restores
quantity: nil,
InAppPurchaseReceipt(
quantity: 1,
productIdentifier: "monthly",
transactionIdentifier: "1000000166965327",
originalTransactionIdentifier: "1000000166965150",
@@ -85,10 +84,10 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
originalPurchaseDate: Date.demoDate(string: "2015-08-10T06:53:18Z"),
subscriptionExpirationDate: Date.demoDate(string: "2015-08-10T06:59:32Z"),
cancellationDate: nil,
webOrderLineItemId: nil
webOrderLineItemId: 1000000030274154
),
InAppPurchaseReceipt(
quantity: nil,
quantity: 1,
productIdentifier: "monthly",
transactionIdentifier: "1000000166965895",
originalTransactionIdentifier: "1000000166965150",
@@ -96,10 +95,10 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
originalPurchaseDate: Date.demoDate(string: "2015-08-10T06:57:34Z"),
subscriptionExpirationDate: Date.demoDate(string: "2015-08-10T07:04:32Z"),
cancellationDate: nil,
webOrderLineItemId: nil
webOrderLineItemId: 1000000030274165
),
InAppPurchaseReceipt(
quantity: nil,
quantity: 1,
productIdentifier: "monthly",
transactionIdentifier: "1000000166967152",
originalTransactionIdentifier: "1000000166965150",
@@ -107,10 +106,10 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
originalPurchaseDate: Date.demoDate(string: "2015-08-10T07:02:33Z"),
subscriptionExpirationDate: Date.demoDate(string: "2015-08-10T07:09:32Z"),
cancellationDate: nil,
webOrderLineItemId: nil
webOrderLineItemId: 1000000030274192
),
InAppPurchaseReceipt(
quantity: nil,
quantity: 1,
productIdentifier: "monthly",
transactionIdentifier: "1000000166967484",
originalTransactionIdentifier: "1000000166965150",
@@ -118,10 +117,10 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
originalPurchaseDate: Date.demoDate(string: "2015-08-10T07:08:30Z"),
subscriptionExpirationDate: Date.demoDate(string: "2015-08-10T07:14:32Z"),
cancellationDate: nil,
webOrderLineItemId: nil
webOrderLineItemId: 1000000030274219
),
InAppPurchaseReceipt(
quantity: nil,
quantity: 1,
productIdentifier: "monthly",
transactionIdentifier: "1000000166967782",
originalTransactionIdentifier: "1000000166965150",
@@ -129,8 +128,9 @@ class LocalReceiptValidationInAppPurchaseTests: XCTestCase {
originalPurchaseDate: Date.demoDate(string: "2015-08-10T07:12:34Z"),
subscriptionExpirationDate: Date.demoDate(string: "2015-08-10T07:19:32Z"),
cancellationDate: nil,
webOrderLineItemId: nil
webOrderLineItemId: 1000000030274249
)
])
]
)
}
}
@@ -1,19 +1,19 @@
//
// LocalReceiptValidationTests.swift
// Hekate_macOSTests
// AppReceiptValidationTests.swift
// AppReceiptValidator_macOSTests
//
// Created by Hannes Oud on 04.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import Hekate
import AppReceiptValidator
import XCTest
class LocalReceiptValidationTests: XCTestCase {
class AppReceiptValidationTests: XCTestCase {
private let receiptValidator = LocalReceiptValidator()
private let receiptValidator = AppReceiptValidator()
private let exampleDeviceIdentifier = LocalReceiptValidator.Parameters.DeviceIdentifier(base64Encoded: "bEAItZRe")!
private let exampleDeviceIdentifier = AppReceiptValidator.Parameters.DeviceIdentifier(base64Encoded: "bEAItZRe")!
func testFailedReceiptValidating() {
guard let data = assertTestAsset(filename: "not_a_receipt") else { return }
@@ -27,7 +27,7 @@ class LocalReceiptValidationTests: XCTestCase {
return
}
if error != LocalReceiptValidator.Error.emptyReceiptContents {
if error != AppReceiptValidator.Error.emptyReceiptContents {
XCTFail("Unexpected error, expected .emptyReceiptContents, got \(error)")
}
}
@@ -39,7 +39,7 @@ class LocalReceiptValidationTests: XCTestCase {
_ = try receiptValidator.parseReceipt(origin: .data(data))
XCTFail("Unexpectedly succeeded in parsing a non-receipt")
} catch {
guard let e = error as? LocalReceiptValidator.Error, e == LocalReceiptValidator.Error.emptyReceiptContents else {
guard error as? AppReceiptValidator.Error == AppReceiptValidator.Error.emptyReceiptContents else {
XCTFail("Unexpected error, expeced .emptyReceiptContents, got \(error)")
return
}
@@ -74,7 +74,6 @@ class LocalReceiptValidationTests: XCTestCase {
XCTAssertEqual(receipt, expected)
}
func testMindNodeProMacReceiptParsing() {
guard let data = assertTestAsset(filename: "hannes_mac_mindnode_pro_receipt") else { return }
@@ -146,7 +145,7 @@ class LocalReceiptValidationTests: XCTestCase {
)
let result = receiptValidator.validateReceipt {
$0.receiptOrigin = .data(data)
$0.deviceIdentifier = LocalReceiptValidator.Parameters.DeviceIdentifier(base64Encoded: "bEAItZRe")!
$0.deviceIdentifier = AppReceiptValidator.Parameters.DeviceIdentifier(base64Encoded: "bEAItZRe")!
}
guard let receipt = result.receipt else {
XCTFail("Unexpectedly failed parsing a receipt \(result.error!)")
@@ -174,7 +173,7 @@ class LocalReceiptValidationTests: XCTestCase {
$0.receiptOrigin = .data(data)
$0.shouldValidateHash = false
$0.shouldValidateSignaturePresence = false
$0.shouldValidateSignatureAuthenticity = false
$0.signatureValidation = .skip
}
guard let receipt = result.receipt else {
XCTFail("Unexpectedly failed parsing a receipt \(result.error!)")
@@ -209,7 +208,7 @@ class LocalReceiptValidationTests: XCTestCase {
func testNonMindNodeFailingDeprecatedSinglesTypeExpiredAppleCertParsing() {
guard let data = assertB64TestAsset(filename: "deprecatedSinglesTypeExpiredAppleCert_receipt.b64") else { return }
let result = receiptValidator.validateReceipt { (parameters: inout LocalReceiptValidator.Parameters) -> Void in
let result = receiptValidator.validateReceipt { (parameters: inout AppReceiptValidator.Parameters) -> Void in
parameters.receiptOrigin = .data(data)
}
guard let error = result.error else {
@@ -217,7 +216,7 @@ class LocalReceiptValidationTests: XCTestCase {
return
}
if error != LocalReceiptValidator.Error.emptyReceiptContents {
if error != AppReceiptValidator.Error.emptyReceiptContents {
XCTFail("Unexpected error, expeced .emptyReceiptContents, got \(error)")
}
}
@@ -227,7 +226,7 @@ class LocalReceiptValidationTests: XCTestCase {
let result = receiptValidator.validateReceipt {
$0.receiptOrigin = .data(data)
$0.deviceIdentifier = LocalReceiptValidator.Parameters.DeviceIdentifier(uuid: UUID(uuidString: "3B76A7BD-8F5B-46A4-BCB1-CCE8DBD1B3CD")!)
$0.deviceIdentifier = AppReceiptValidator.Parameters.DeviceIdentifier(uuid: UUID(uuidString: "3B76A7BD-8F5B-46A4-BCB1-CCE8DBD1B3CD")!)
}
let expected = Receipt(
bundleIdentifier: "com.mindnode.mindnodetouch",
@@ -277,12 +276,22 @@ class LocalReceiptValidationTests: XCTestCase {
func testiOSParsingPerformance() {
guard let data = assertB64TestAsset(filename: "mindnode_ios_michaelsandbox_receipt1.b64") else { return }
let parameters = LocalReceiptValidator.Parameters.allSteps.with {
let parameters = AppReceiptValidator.Parameters.default.with {
$0.receiptOrigin = .data(data)
$0.deviceIdentifier = LocalReceiptValidator.Parameters.DeviceIdentifier(uuid: UUID(uuidString: "3B76A7BD-8F5B-46A4-BCB1-CCE8DBD1B3CD")!)
$0.deviceIdentifier = AppReceiptValidator.Parameters.DeviceIdentifier(uuid: UUID(uuidString: "3B76A7BD-8F5B-46A4-BCB1-CCE8DBD1B3CD")!)
}
measure {
_ = receiptValidator.validateReceipt(parameters: parameters)
}
}
}
// MARK: - AppReceiptValidator + Convenience
extension AppReceiptValidator {
/// Validates a receipt and returns the result using the parameters `AppReceiptValidator.Parameters.default`, which can be further configured in the passed block.
func validateReceipt(configuration: (inout Parameters) -> Void) -> Result {
return validateReceipt(parameters: Parameters.default.with(block: configuration))
}
}
@@ -0,0 +1,56 @@
//
// DeviceIdentifierTests.swift
// AppReceiptValidator
//
// Created by Hannes Oud on 22.11.18.
// Copyright © 2018 IdeasOnCanvas GmbH. All rights reserved.
//
@testable import AppReceiptValidator
import Foundation
import XCTest
final class DeviceIdentifierTests: XCTestCase {
func testBase64Initializer() {
let deviceIdentifier = AppReceiptValidator.Parameters.DeviceIdentifier(base64Encoded: "bEAItZRe")
XCTAssertNotNil(deviceIdentifier)
}
func testMacAddressInitializer() {
XCTAssertNotNil(AppReceiptValidator.Parameters.DeviceIdentifier(macAddress: "00:0d:3f:cd:02:5f"))
}
func testMacAddressInitializerOtherSeparator() {
XCTAssertNotNil(AppReceiptValidator.Parameters.DeviceIdentifier(macAddress: "00-0d-3f-cd-02-5f", separator: "-"))
}
func testUUIDInitializer() {
XCTAssertNotNil(AppReceiptValidator.Parameters.DeviceIdentifier(uuid: UUID()))
}
func testCurrent() {
let deviceIdentifierData = AppReceiptValidator.Parameters.DeviceIdentifier.currentDevice.getData()
XCTAssertNotNil(deviceIdentifierData)
}
#if os(macOS)
func testMacAddressRetrieval() {
guard let (data, string) = AppReceiptValidator.Parameters.DeviceIdentifier.getPrimaryNetworkMACAddress() else {
XCTFail("Failed to get device mac address")
return
}
guard let deviceIdentifierData = AppReceiptValidator.Parameters.DeviceIdentifier.currentDevice.getData() else {
XCTFail("Failed to get device mac address")
return
}
XCTAssertEqual(data, deviceIdentifierData)
guard let deviceIdentifierFromString = AppReceiptValidator.Parameters.DeviceIdentifier(macAddress: string) else {
XCTFail("Failed to get device identifier from mac address string")
return
}
XCTAssertEqual(deviceIdentifierFromString.getData(), deviceIdentifierData)
}
#endif
}
@@ -0,0 +1,28 @@
//
// ReceiptDateFormatterTests.swift
// AppReceiptValidator
//
// Created by Hannes Oud on 09.10.20.
// Copyright © 2020 IdeasOnCanvas GmbH. All rights reserved.
//
import AppReceiptValidator
import Foundation
import XCTest
final class ReceiptDateFormatterTests: XCTestCase {
func testDateFormatting() throws {
let dateStrings = [
"2020-01-01T12:00:00Z",
"2020-01-01T12:00:00.123Z",
"2020-01-01T12:00:00.999Z",
"2020-01-01T12:00:01Z"
]
for dateString in dateStrings {
let parsed = try XCTUnwrap(AppReceiptValidator.ReceiptDateFormatter.date(from: dateString))
XCTAssertEqual(AppReceiptValidator.ReceiptDateFormatter.string(from: parsed), dateString)
}
}
}
@@ -1,21 +1,21 @@
//
// Date+Convenience.swift
// Hekate iOS
// AppReceiptValidator iOS
//
// Created by Hannes Oud on 07.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import AppReceiptValidator
import Foundation
import Hekate
extension Date {
/// Returns a date which is independent of the current date, based on the LocalReceiptValidators dataformatter. Useful for tests.
/// Returns a date which is independent of the current date, based on the AppReceiptValidator's Date formatter. Useful for tests.
/// - Parameter string: Example "2018-07-12T10:57:42Z", defaults to "2017-01-01T12:00:00Z"
/// - Returns: The date
public static func demoDate(string: String = "2017-01-01T12:00:00Z") -> Date {
guard let date = LocalReceiptValidator.asn1DateFormatter.date(from: string) else {
guard let date = AppReceiptValidator.asn1DateFormatter.date(from: string) else {
fatalError("Failed to deserialize expected date \(string), use format like '2017-01-01T12:00:00Z'")
}
@@ -0,0 +1,71 @@
//
// KnownOrUnknown.swift
// AppReceiptValidator
//
// Created by Hannes Oud on 08.01.18.
// Copyright © 2018 IdeasOnCanvas GmbH. All rights reserved.
//
// MARK: - KnownOrUnknown
/// A known or unknown RawRepresentable
///
/// - known: the raw value is known and could be assigned to a known strong value type
/// - unknown: the raw value is unknown and is stored as is
public enum KnownOrUnknown<Known: RawRepresentable> where Known.RawValue: Hashable {
public typealias Unknown = Known.RawValue
case known(value: Known)
case unknown(rawValue: Unknown)
}
// MARK: - RawRepresentable
extension KnownOrUnknown: RawRepresentable {
public typealias RawValue = Unknown
public init?(rawValue: Unknown) {
if let known = Known(rawValue: rawValue) {
self = .known(value: known)
} else {
self = .unknown(rawValue: rawValue)
}
}
public var rawValue: Unknown {
switch self {
case .known(let value):
return value.rawValue
case .unknown(let rawValue):
return rawValue
}
}
}
// MARK: - Hashable
extension KnownOrUnknown: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.rawValue.hashValue)
}
public static func == (lhs: KnownOrUnknown<Known>, rhs: KnownOrUnknown<Known>) -> Bool {
return lhs.rawValue == rhs.rawValue
}
}
// MARK: - CustomStringConvertible
extension KnownOrUnknown: CustomStringConvertible {
public var description: String {
switch self {
case .known(let value):
return "\(value)"
case .unknown(let rawValue):
return "\"\(rawValue)\""
}
}
}
@@ -1,6 +1,6 @@
//
// TestAssetLoading.swift
// Hekate_macOSTests
// AppReceiptValidator_macOSTests
//
// Created by Hannes Oud on 04.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:/Users/hannes/Projekte/Workspace/iOS/IdeasOnCanvas/AppReceiptValidator/AppReceiptValidator/AppReceiptValidator.xcodeproj">
</FileRef>
</Workspace>
@@ -2,9 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -15,9 +15,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4E31F5D691400E86FE1"
BuildableName = "Hekate Demo iOS.app"
BlueprintName = "Hekate Demo iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo iOS.app"
BlueprintName = "AppReceiptValidator Demo iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
@@ -29,9 +29,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095A81F6001800095729B"
BuildableName = "Hekate Tests iOS.xctest"
BlueprintName = "Hekate Tests iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Tests iOS.xctest"
BlueprintName = "AppReceiptValidator Tests iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
@@ -40,37 +40,35 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095A81F6001800095729B"
BuildableName = "Hekate Tests iOS.xctest"
BlueprintName = "Hekate Tests iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4E31F5D691400E86FE1"
BuildableName = "Hekate Demo iOS.app"
BlueprintName = "Hekate Demo iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo iOS.app"
BlueprintName = "AppReceiptValidator Demo iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095A81F6001800095729B"
BuildableName = "AppReceiptValidator Tests iOS.xctest"
BlueprintName = "AppReceiptValidator Tests iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -82,13 +80,11 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4E31F5D691400E86FE1"
BuildableName = "Hekate Demo iOS.app"
BlueprintName = "Hekate Demo iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo iOS.app"
BlueprintName = "AppReceiptValidator Demo iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -101,9 +97,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4E31F5D691400E86FE1"
BuildableName = "Hekate Demo iOS.app"
BlueprintName = "Hekate Demo iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo iOS.app"
BlueprintName = "AppReceiptValidator Demo iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -15,9 +15,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095801F6000A40095729B"
BuildableName = "Hekate Demo macOS.app"
BlueprintName = "Hekate Demo macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo macOS.app"
BlueprintName = "AppReceiptValidator Demo macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
@@ -29,9 +29,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095911F6000A40095729B"
BuildableName = "Hekate Tests macOS.xctest"
BlueprintName = "Hekate Tests macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Tests macOS.xctest"
BlueprintName = "AppReceiptValidator Tests macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
@@ -40,37 +40,35 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095911F6000A40095729B"
BuildableName = "Hekate Tests macOS.xctest"
BlueprintName = "Hekate Tests macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095801F6000A40095729B"
BuildableName = "Hekate Demo macOS.app"
BlueprintName = "Hekate Demo macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo macOS.app"
BlueprintName = "AppReceiptValidator Demo macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095911F6000A40095729B"
BuildableName = "AppReceiptValidator Tests macOS.xctest"
BlueprintName = "AppReceiptValidator Tests macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -82,13 +80,11 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095801F6000A40095729B"
BuildableName = "Hekate Demo macOS.app"
BlueprintName = "Hekate Demo macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo macOS.app"
BlueprintName = "AppReceiptValidator Demo macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -101,9 +97,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095801F6000A40095729B"
BuildableName = "Hekate Demo macOS.app"
BlueprintName = "Hekate Demo macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator Demo macOS.app"
BlueprintName = "AppReceiptValidator Demo macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -15,9 +15,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4B41F5D684C00E86FE1"
BuildableName = "Hekate.framework"
BlueprintName = "Hekate iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
@@ -26,18 +26,35 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4B41F5D684C00E86FE1"
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095A81F6001800095729B"
BuildableName = "AppReceiptValidator Tests iOS.xctest"
BlueprintName = "AppReceiptValidator Tests iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -48,13 +65,11 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4B41F5D684C00E86FE1"
BuildableName = "Hekate.framework"
BlueprintName = "Hekate iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -66,9 +81,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4B41F5D684C00E86FE1"
BuildableName = "Hekate.framework"
BlueprintName = "Hekate iOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator iOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -15,23 +15,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4C11F5D687400E86FE1"
BuildableName = "Hekate.framework"
BlueprintName = "Hekate macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F5321F5D894900E86FE1"
BuildableName = "Hekate_macOSTests.xctest"
BlueprintName = "Hekate_macOSTests"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
@@ -40,37 +26,35 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F5321F5D894900E86FE1"
BuildableName = "Hekate_macOSTests.xctest"
BlueprintName = "Hekate_macOSTests"
ReferencedContainer = "container:Hekate.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4C11F5D687400E86FE1"
BuildableName = "Hekate.framework"
BlueprintName = "Hekate macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D19095911F6000A40095729B"
BuildableName = "AppReceiptValidator Tests macOS.xctest"
BlueprintName = "AppReceiptValidator Tests macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -81,13 +65,11 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4C11F5D687400E86FE1"
BuildableName = "Hekate.framework"
BlueprintName = "Hekate macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -99,9 +81,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D6F4C11F5D687400E86FE1"
BuildableName = "Hekate.framework"
BlueprintName = "Hekate macOS"
ReferencedContainer = "container:Hekate.xcodeproj">
BuildableName = "AppReceiptValidator.framework"
BlueprintName = "AppReceiptValidator macOS"
ReferencedContainer = "container:AppReceiptValidator.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
@@ -1,6 +1,6 @@
//
// LocalReceiptValidator+Parameters.swift
// Hekate
// AppReceiptValidator+Parameters.swift
// AppReceiptValidator
//
// Created by Hannes Oud on 06.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
@@ -8,39 +8,51 @@
import Foundation
public extension LocalReceiptValidator {
public extension AppReceiptValidator {
/// Describes how to validate a receipt, and how/where to obtain the dependencies (receipt, deviceIdentifier, apple root certificate)
/// Use .allSteps to initialize the standard parameters. By default, no `propertyValidations` are active.
public struct Parameters {
/// Use .default to initialize the standard parameters. By default, no `propertyValidations` are active.
struct Parameters {
// MARK: - Properties
public var receiptOrigin: ReceiptOrigin = .installedInMainBundle
public var shouldValidateSignaturePresence: Bool = true
public var shouldValidateSignatureAuthenticity: Bool = true
public var signatureValidation: SignatureValidation = .shouldValidate(rootCertificateOrigin: .cerFileBundledWithAppReceiptValidator)
public var shouldValidateHash: Bool = true
public var deviceIdentifier: DeviceIdentifier = .currentDevice
public var rootCertificateOrigin: RootCertificateOrigin = .cerFileBundledWithHekate
public var propertyValidations: [PropertyValidation] = []
// MARK: - Lifecycle
/// Or use .default to initialize a sensible defaults
public init(receiptOrigin: ReceiptOrigin, shouldValidateSignaturePresence: Bool, signatureValidation: SignatureValidation, shouldValidateHash: Bool, deviceIdentifier: DeviceIdentifier, propertyValidations: [PropertyValidation]) {
self.receiptOrigin = receiptOrigin
self.shouldValidateSignaturePresence = shouldValidateSignaturePresence
self.signatureValidation = signatureValidation
self.shouldValidateHash = shouldValidateHash
self.deviceIdentifier = deviceIdentifier
}
/// Either use `.default` to get a default preset, or specify everything via the complete init() with all parameters.
private init() {}
public static var `default`: Parameters {
return Parameters()
}
/// Configure an instance with a block
public func with(block: (inout Parameters) -> Void) -> Parameters {
var copy = self
block(&copy)
return copy
}
/// Use .allSteps to initialize
private init() {}
public static var allSteps: Parameters {
return Parameters()
}
}
}
// MARK: - ReceiptOrigin
extension LocalReceiptValidator.Parameters {
extension AppReceiptValidator.Parameters {
/// Used for obtaining the receipt data to parse or validate.
///
@@ -50,11 +62,14 @@ extension LocalReceiptValidator.Parameters {
case installedInMainBundle
case data(Data)
case dynamic(() -> Data?)
public func loadData() -> Data? {
switch self {
case .data(let data):
return data
case .dynamic(let maker):
return maker()
case .installedInMainBundle:
guard let receiptUrl = Bundle.main.appStoreReceiptURL else { return nil }
guard (try? receiptUrl.checkResourceIsReachable()) ?? false else { return nil }
@@ -67,13 +82,13 @@ extension LocalReceiptValidator.Parameters {
// MARK: - DeviceIdentifier
public extension LocalReceiptValidator.Parameters {
public extension AppReceiptValidator.Parameters {
/// Used for calculating/validating the SHA1-Hash part of a receipt.
///
/// - currentDevice: Obtains it from the system location: MAC Adress on macOS, deviceIdentifierForVendor on iOS
/// - currentDevice: Obtains it from the system location: MAC Address on macOS, deviceIdentifierForVendor on iOS
/// - data: Specific Data to use
public enum DeviceIdentifier {
enum DeviceIdentifier {
case currentDevice
case data(Data)
@@ -87,6 +102,20 @@ public extension LocalReceiptValidator.Parameters {
self = .data(uuid.data)
}
/// Returns .data by parsing a MAC Address String
///
/// - Parameters:
/// - macAddress: A MAC Address of the form "00:0d:3f:cd:02:5f"
/// - separator: Defaults to `":"`
///
/// - Note: on macOS the MAC Addresses can be read from terminal command `ifconfig` looking for ther `ether` entry of `5e`.
public init?(macAddress: String, separator: String = ":") {
let bytes = macAddress.components(separatedBy: separator).compactMap { UInt8($0, radix: 16) }
guard bytes.count == 6 else { return nil }
self = .data(Data(bytes))
}
public func getData() -> Data? {
switch self {
case .data(let data):
@@ -102,23 +131,37 @@ public extension LocalReceiptValidator.Parameters {
}
}
// MARK: - SignatureValidation
extension AppReceiptValidator.Parameters {
/// Used for verifying the signature
///
/// - skip: The signature authenticity is not validated
/// - shouldValidate: The signature is verified against the provided root certificate
public enum SignatureValidation {
case skip
case shouldValidate(rootCertificateOrigin: RootCertificateOrigin)
}
}
// MARK: - RootCertificateOrigin
extension LocalReceiptValidator.Parameters {
extension AppReceiptValidator.Parameters {
/// Instructs how to find the Apple root certificate for receipt validation.
///
/// - cerFileBundledWithHekate: Uses the "AppleIncRootCertificate.cer" bundled with Hekate
/// - cerFileBundledWithAppReceiptValidator: Uses the "AppleIncRootCertificate.cer" bundled with AppReceiptValidator
/// - data: Specific Data to use
public enum RootCertificateOrigin {
case cerFileBundledWithHekate
case cerFileBundledWithAppReceiptValidator
case data(Data)
public func loadData() -> Data? {
switch self {
case .data(let data):
return data
case .cerFileBundledWithHekate:
case .cerFileBundledWithAppReceiptValidator:
guard let appleRootCertificateURL = Bundle(for: BundleToken.self).url(forResource: "AppleIncRootCertificate", withExtension: "cer") else { return nil }
return try? Data(contentsOf: appleRootCertificateURL)
@@ -128,10 +171,9 @@ extension LocalReceiptValidator.Parameters {
private class BundleToken {}
}
// MARK: - PropertyValidation
extension LocalReceiptValidator.Parameters {
extension AppReceiptValidator.Parameters {
/// Compares a String property of a receipt with an info dictionary entry or a provided value.
///
@@ -171,7 +213,7 @@ extension LocalReceiptValidator.Parameters {
let expected = self.getExpectedValue()
if self.propertyValue(of: receipt) != expected {
throw LocalReceiptValidator.Error.propertyValueMismatch
throw AppReceiptValidator.Error.propertyValueMismatch
}
}
@@ -1,13 +1,13 @@
//
// LocalReceiptValidator.swift
// Hekate iOS
// AppReceiptValidator.swift
// AppReceiptValidator iOS
//
// Created by Hannes Oud on 04.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import AppReceiptValidator.OpenSSL
import Foundation
import Hekate.OpenSSL
/// Apple guide: https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Introduction.html
///
@@ -15,7 +15,7 @@ import Hekate.OpenSSL
///
/// More: See README.md
/// - Note: If on iOS, use this only on Main Queue, because UIDevice is called
public struct LocalReceiptValidator {
public struct AppReceiptValidator {
// MARK: - Lifecycle
@@ -23,13 +23,8 @@ public struct LocalReceiptValidator {
// MARK: - Local Receipt Validation
/// Validates a local receipt and returns the result using the parameters `LocalReceiptValidator.Parameters.allSteps`, which can be further configured in the passed block.
public func validateReceipt(configuration: (inout Parameters) -> Void) -> Result {
return validateReceipt(parameters: Parameters.allSteps.with(block: configuration))
}
/// Validates a local receipt and returns the result using the passed parameters.
public func validateReceipt(parameters: Parameters = Parameters.allSteps) -> Result {
public func validateReceipt(parameters: Parameters = Parameters.default) -> Result {
var data: Data?
var deviceIdData: Data?
do {
@@ -42,13 +37,13 @@ public struct LocalReceiptValidator {
if parameters.shouldValidateSignaturePresence {
try self.checkSignaturePresence(pkcs7: receiptContainer)
}
if parameters.shouldValidateSignatureAuthenticity {
guard let appleRootCertificateData = parameters.rootCertificateOrigin.loadData() else { throw Error.appleRootCertificateNotFound }
if case .shouldValidate(let rootCertificateOrigin) = parameters.signatureValidation {
guard let appleRootCertificateData = rootCertificateOrigin.loadData() else { throw Error.appleRootCertificateNotFound }
try self.checkSignatureAuthenticity(pkcs7: receiptContainer, appleRootCertificateData: appleRootCertificateData)
}
let receipt = try self.parseReceipt(pkcs7: receiptContainer)
let receipt = try self.parseReceipt(pkcs7: receiptContainer).receipt
try self.validateProperties(receipt: receipt, validations: parameters.propertyValidations)
@@ -59,8 +54,8 @@ public struct LocalReceiptValidator {
}
return .success(receipt, receiptData: receiptData, deviceIdentifier: deviceIdData)
} catch {
assert(error is LocalReceiptValidator.Error)
return .error(error as? LocalReceiptValidator.Error ?? .unknown, receiptData: data, deviceIdentifier: deviceIdData)
assert(error is AppReceiptValidator.Error)
return .error(error as? AppReceiptValidator.Error ?? .unknown, receiptData: data, deviceIdentifier: deviceIdData)
}
}
@@ -73,29 +68,31 @@ public struct LocalReceiptValidator {
/// Parse a local receipt without any validation.
///
/// - Parameter origin: How to load the receipt.
/// - Returns: The Parsed receipt.
/// - Throws: A Error. Especially Error.couldNotFindReceipt if the receipt cannot be loaded/found.
/// - Returns: The parsed receipt.
/// - Throws: Especially Error.couldNotFindReceipt if the receipt cannot be loaded/found.
public func parseReceipt(origin: Parameters.ReceiptOrigin) throws -> Receipt {
guard let receiptData = origin.loadData() else { throw Error.couldNotFindReceipt }
let receiptContainer = try extractPKCS7Container(data: receiptData)
return try parseReceipt(pkcs7: receiptContainer)
let receiptContainer = try self.extractPKCS7Container(data: receiptData)
return try parseReceipt(pkcs7: receiptContainer).receipt
}
/// Uses receipt-conform representation of dates like "2017-01-01T12:00:00Z"
public static let asn1DateFormatter: DateFormatter = {
// Date formatter code from https://www.objc.io/issues/17-security/receipt-validation/#parsing-the-receipt
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
return dateFormatter
}()
/// Parse the local receipt and it's unofficial attributes without any validation.
///
/// - Parameter origin: How to load the receipt.
/// - Returns: The parsed receipt.
/// - Throws: Especially Error.couldNotFindReceipt if the receipt cannot be loaded/found.
public func parseUnofficialReceipt(origin: Parameters.ReceiptOrigin) throws -> (receipt: Receipt, unofficialReceipt: UnofficialReceipt) {
guard let receiptData = origin.loadData() else { throw Error.couldNotFindReceipt }
let receiptContainer = try self.extractPKCS7Container(data: receiptData)
return try parseReceipt(pkcs7: receiptContainer, parseUnofficialParts: true)
}
}
// MARK: - Full Validation
private extension LocalReceiptValidator {
private extension AppReceiptValidator {
func validateHash(receipt: Receipt, deviceIdentifierData: Data) throws {
// Make sure that the Receipt instances has non-nil values needed for hash comparison
@@ -110,15 +107,14 @@ private extension LocalReceiptValidator {
var sha1Context = SHA_CTX()
SHA1_Init(&sha1Context)
deviceIdentifierData.withUnsafeBytes { pointer -> Void in
SHA1_Update(&sha1Context, pointer, deviceIdentifierData.count)
SHA1_Update(&sha1Context, pointer.baseAddress, deviceIdentifierData.count)
}
receiptOpaqueValueData.withUnsafeBytes { pointer -> Void in
SHA1_Update(&sha1Context, pointer, receiptOpaqueValueData.count)
SHA1_Update(&sha1Context, pointer.baseAddress, receiptOpaqueValueData.count)
}
receiptBundleIdData.withUnsafeBytes { pointer -> Void in
SHA1_Update(&sha1Context, pointer, receiptBundleIdData.count)
SHA1_Update(&sha1Context, pointer.baseAddress, receiptBundleIdData.count)
}
SHA1_Final(&computedHash, &sha1Context)
@@ -133,7 +129,7 @@ private extension LocalReceiptValidator {
// MARK: - PKCS7 Extraction
private extension LocalReceiptValidator {
private extension AppReceiptValidator {
func extractPKCS7Container(data: Data) throws -> PKCS7Wrapper {
let receiptBIO = BIOWrapper(data: data)
@@ -152,7 +148,7 @@ private extension LocalReceiptValidator {
// MARK: - PKCS7 Signature checking
private extension LocalReceiptValidator {
private extension AppReceiptValidator {
func checkSignaturePresence(pkcs7: PKCS7Wrapper) throws {
let pkcs7SignedTypeCode = OBJ_obj2nid(pkcs7.pkcs7.pointee.type)
@@ -190,17 +186,24 @@ private extension LocalReceiptValidator {
// MARK: - Parsing of properties
private extension LocalReceiptValidator {
private extension AppReceiptValidator {
// swiftlint:disable:next cyclomatic_complexity
func parseReceipt(pkcs7: PKCS7Wrapper) throws -> Receipt {
func parseReceipt(pkcs7: PKCS7Wrapper, parseUnofficialParts: Bool = false) throws -> (receipt: Receipt, unofficialReceipt: UnofficialReceipt) {
guard let contents = pkcs7.pkcs7.pointee.d.sign.pointee.contents, let octets = contents.pointee.d.data else { throw Error.malformedReceipt }
guard let initialPointer = UnsafePointer(octets.pointee.data) else { throw Error.malformedReceipt }
let length = Int(octets.pointee.length)
var receipt = Receipt()
var unofficialReceipt = UnofficialReceipt(entries: [])
try self.parseASN1Set(pointer: initialPointer, length: length) { attributeType, value in
guard let attribute = KnownReceiptAttribute(rawValue: attributeType) else { return }
guard let attribute = KnownReceiptAttribute(rawValue: attributeType) else {
if parseUnofficialParts {
let entry = parseUnofficialReceiptEntry(attributeType: attributeType, value: value)
unofficialReceipt.entries.append(entry)
}
return
}
switch attribute {
case .bundleIdentifier:
@@ -223,34 +226,36 @@ private extension LocalReceiptValidator {
receipt.originalAppVersion = value.unwrappedStringValue
case .expirationDate:
receipt.expirationDate = value.unwrappedDateValue
break
}
}
return receipt
return (receipt: receipt, unofficialReceipt: unofficialReceipt)
}
// swiftlint:disable:next cyclomatic_complexity
private func parseInAppPurchaseReceipt(pointer: UnsafePointer<UInt8>, length: Int) throws -> InAppPurchaseReceipt {
var inAppPurchaseReceipt = InAppPurchaseReceipt()
try self.parseASN1Set(pointer: pointer, length: length) { attributeType, value in
guard let attribute = KnownInAppPurchaseAttribute(rawValue: attributeType) else { return }
guard let value = value.unwrapped else { return } // always unwrap set members
switch attribute {
case .quantity:
inAppPurchaseReceipt.quantity = value.intValue
case .productIdentifier:
inAppPurchaseReceipt.productIdentifier = value.unwrappedStringValue
inAppPurchaseReceipt.productIdentifier = value.stringValue
case .transactionIdentifier:
inAppPurchaseReceipt.transactionIdentifier = value.unwrappedStringValue
inAppPurchaseReceipt.transactionIdentifier = value.stringValue
case .originalTransactionIdentifier:
inAppPurchaseReceipt.originalTransactionIdentifier = value.unwrappedStringValue
inAppPurchaseReceipt.originalTransactionIdentifier = value.stringValue
case .purchaseDate:
inAppPurchaseReceipt.purchaseDate = value.unwrappedDateValue
inAppPurchaseReceipt.purchaseDate = value.dateValue
case .originalPurchaseDate:
inAppPurchaseReceipt.originalPurchaseDate = value.unwrappedDateValue
inAppPurchaseReceipt.originalPurchaseDate = value.dateValue
case .subscriptionExpirationDate:
inAppPurchaseReceipt.subscriptionExpirationDate = value.unwrappedDateValue
inAppPurchaseReceipt.subscriptionExpirationDate = value.dateValue
case .cancellationDate:
inAppPurchaseReceipt.cancellationDate = value.unwrappedDateValue
inAppPurchaseReceipt.cancellationDate = value.dateValue
case .webOrderLineItemId:
inAppPurchaseReceipt.webOrderLineItemId = value.intValue
}
@@ -258,6 +263,28 @@ private extension LocalReceiptValidator {
return inAppPurchaseReceipt
}
private func parseUnofficialReceiptEntry(attributeType: Int32, value: ASN1Object) -> UnofficialReceipt.Entry {
switch KnownUnofficialReceiptAttribute(rawValue: attributeType) {
case .some(let meaning):
switch meaning.parsingType {
case .string:
return UnofficialReceipt.Entry(attributeNumber: attributeType, meaning: meaning, value: value.unwrappedStringValue.map { UnofficialReceipt.Entry.Value.string($0) })
case .date:
return UnofficialReceipt.Entry(attributeNumber: attributeType, meaning: meaning, value: value.unwrappedDateValue.map { UnofficialReceipt.Entry.Value.date($0) })
case .data:
return UnofficialReceipt.Entry(attributeNumber: attributeType, meaning: meaning, value: value.dataValue.map { UnofficialReceipt.Entry.Value.bytes($0) })
}
case .none:
if let string = value.unwrappedStringValue {
return UnofficialReceipt.Entry(attributeNumber: attributeType, meaning: nil, value: .string(string))
}
if let string = value.stringValue {
return UnofficialReceipt.Entry(attributeNumber: attributeType, meaning: nil, value: .string(string))
}
return UnofficialReceipt.Entry(attributeNumber: attributeType, meaning: nil, value: value.dataValue.map { UnofficialReceipt.Entry.Value.bytes($0) })
}
}
private func parseASN1Set(pointer initialPointer: UnsafePointer<UInt8>, length: Int, valueAttributeAction: (_ attributeType: Int32, _ value: ASN1Object) throws -> Void) throws {
var pointer: UnsafePointer<UInt8>? = initialPointer
let limit = initialPointer.advanced(by: length)
@@ -286,7 +313,7 @@ private extension LocalReceiptValidator {
// MARK: Receipt ASN1 Sequence Attribute Types
private extension LocalReceiptValidator {
private extension AppReceiptValidator {
/// See Receipt.swift for details and a link to Apple reference
enum KnownReceiptAttribute: Int32 {
@@ -298,13 +325,6 @@ private extension LocalReceiptValidator {
case receiptCreationDate = 12
case originalAppVersion = 19
case expirationDate = 21
// Unofficial list found (not necessarily complete):
// - 18: some date in the past
// - 8: some date in the past, same as receiptCreationDate possibly
// - 0: String, probably Provisioning-Type, Encountered Values: "Production", "ProductionSandbox"
// - 10: String, probably Age Description, example Value "4+"
// - and of unknown type 14(L=3), 25(L=3), 11(L=4), 13(L=4), 1(L=6), 9(L=6), 16(L=6), 15(L=8), 7(L=66), 6(L=69 variable)
}
/// See Receipt.swift for details and a link to Apple reference
@@ -321,14 +341,67 @@ private extension LocalReceiptValidator {
}
}
// MARK: - ReceiptDateFormatter
extension AppReceiptValidator {
/// Static formatting methods to use for string encoded date values in receipts
public enum ReceiptDateFormatter {
/// Uses receipt-conform representation of dates like "2017-01-01T12:00:00Z",
/// as a fallback, dates like "2017-01-01T12:00:00.123Z" are also parsed.
public static func date(from string: String) -> Date? {
return self.asn1DateFormatter.date(from: string) // expected
?? self.fallbackDateFormatterWithMS.date(from: string) // try again with milliseconds
}
/// Returns receipt-conform string representation of dates like "2017-01-01T12:00:00Z",
/// but if the date has sub-second fractions a millisecond representation like "2017-01-01T12:00:00.123Z" is returned.
public static func string(from date: Date) -> String {
if floor(date.timeIntervalSince1970) == date.timeIntervalSince1970 {
// Integer seconds granularity is what we expect
return self.asn1DateFormatter.string(from: date)
} else {
// millis seconds granularity is what we expect
return self.fallbackDateFormatterWithMS.string(from: date)
}
}
/// Uses receipt-conform representation of dates like "2017-01-01T12:00:00Z"
static let asn1DateFormatter: DateFormatter = {
// Date formatter code from https://www.objc.io/issues/17-security/receipt-validation/#parsing-the-receipt
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
return dateFormatter
}()
/// Uses receipt-conform representation of dates like "2017-01-01T12:00:00.123Z"
///
/// This is not the officially intended format, but added after hearing reports about new format adding ms https://twitter.com/depth42/status/1314179654811607041
private static let fallbackDateFormatterWithMS: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
return dateFormatter
}()
}
/// Uses receipt-conform representation of dates like "2017-01-01T12:00:00Z"
@available(*, deprecated, message: "Use AppReceiptValidator.ReceiptDateFormatter.string(from:) or AppReceiptValidator.ReceiptDateFormatter.date(from:) instead, to cover unexpected date formats")
public static let asn1DateFormatter: DateFormatter = ReceiptDateFormatter.asn1DateFormatter
}
// MARK: - Result
extension LocalReceiptValidator {
extension AppReceiptValidator {
public enum Result {
case success(Receipt, receiptData: Data, deviceIdentifier: Data?)
case error(LocalReceiptValidator.Error, receiptData: Data?, deviceIdentifier: Data?)
case error(AppReceiptValidator.Error, receiptData: Data?, deviceIdentifier: Data?)
public var receipt: Receipt? {
switch self {
@@ -339,7 +412,7 @@ extension LocalReceiptValidator {
}
}
public var error: LocalReceiptValidator.Error? {
public var error: AppReceiptValidator.Error? {
switch self {
case .success:
return nil
@@ -372,7 +445,7 @@ extension LocalReceiptValidator {
// MARK: - Error
extension LocalReceiptValidator {
extension AppReceiptValidator {
public enum Error: Int, Swift.Error {
case couldNotFindReceipt
@@ -1,6 +1,6 @@
//
// DeviceIdentifier+installedDeviceIdentifier_iOS.swift
// Hekate macOS
// AppReceiptValidator macOS
//
// Created by Hannes Oud on 06.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
@@ -8,7 +8,7 @@
import UIKit
extension LocalReceiptValidator.Parameters.DeviceIdentifier {
extension AppReceiptValidator.Parameters.DeviceIdentifier {
/// On iOS this is the UIDevice's identifierForVendor UUID data
static var installedDeviceIdentifierData: Data? {
@@ -1,6 +1,6 @@
//
// DeviceIdentifier+installedDeviceIdentifier macOS.swift
// Hekate macOS
// AppReceiptValidator macOS
//
// Created by Hannes Oud on 06.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
@@ -9,7 +9,7 @@
import Foundation
import IOKit
extension LocalReceiptValidator.Parameters.DeviceIdentifier {
extension AppReceiptValidator.Parameters.DeviceIdentifier {
/// On mac this is the primary network interface's MAC Adress as bytes
static var installedDeviceIdentifierData: Data? {
@@ -20,7 +20,7 @@ extension LocalReceiptValidator.Parameters.DeviceIdentifier {
/// Original implementation https://gist.github.com/mminer/82975d3781e2f42fc644d7fbfbf4f905
///
/// - Returns: The MAC Address as Data and String representation
private static func getPrimaryNetworkMACAddress() -> (data: Data, addressString: String)? {
public static func getPrimaryNetworkMACAddress() -> (data: Data, addressString: String)? {
let matching = IOServiceMatching("IOEthernetInterface") as NSMutableDictionary
matching[kIOPropertyMatchKey] = ["IOPrimaryInterface": true]
var servicesIterator: io_iterator_t = 0
@@ -53,6 +53,6 @@ extension LocalReceiptValidator.Parameters.DeviceIdentifier {
.map { String(format: "%02x", $0) }
.joined(separator: ":")
return (data: Data(bytes: address), addressString: addressString)
return (data: Data(address), addressString: addressString)
}
}
@@ -1,13 +1,15 @@
//
// ASN1Helpers.swift
// Hekate
// AppReceiptValidator
//
// Created by Hannes Oud on 07.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import AppReceiptValidator.OpenSSL
import Foundation
import Hekate.OpenSSL
// A resource for ASN1 can be https://www.oss.com/asn1/resources/reference/asn1-reference-card.html
/// An ASN1 Sequence Object. Of interest are the attributeType and the valueObject.
/// The attributeType determines how to interpret the valueObject.
@@ -29,7 +31,7 @@ struct ASN1Sequence {
/// |type | length | value |
/// +----------------+---------+------------------+---------------
///
/// - Note: This object cannot ensure that it's pointers are safe, guarantee this from the outside.
/// - Note: This object cannot ensure that its pointers are safe, guarantee this from the outside.
struct ASN1Object {
fileprivate(set) var type = Int32(0)
@@ -116,7 +118,11 @@ extension ASN1Object {
extension ASN1Object {
/// Unwraps an OCTET_STRING, which is a binary container, that can contain another ASN1Object.
/// This is the case when we are looking at an entry in an ASN1Set
var unwrapped: ASN1Object? {
guard self.type == V_ASN1_OCTET_STRING else { return nil }
guard let endPointer = valuePointer?.advanced(by: length) else { return nil }
var innerPointer = valuePointer
@@ -147,7 +153,7 @@ extension ASN1Object {
var dateValue: Date? {
guard let string = self.stringValue else { return nil }
return LocalReceiptValidator.asn1DateFormatter.date(from: string)
return AppReceiptValidator.ReceiptDateFormatter.date(from: string)
}
}
@@ -155,7 +161,11 @@ extension ASN1Object {
extension ASN1Object {
var intValue: Int? {
var unwrappedIntValue: Int64? {
return self.unwrapped?.intValue
}
var intValue: Int64? {
guard self.type == V_ASN1_INTEGER else { return nil }
var pointer = self.valuePointer
@@ -163,11 +173,11 @@ extension ASN1Object {
defer {
ASN1_INTEGER_free(integer)
}
let result = ASN1_INTEGER_get(integer)
let result = Int64(ASN1_INTEGER_get(integer))
return result
}
func intValue(byAdvancingPointer pointer: inout UnsafePointer<UInt8>?, length: Int? = nil) -> Int? {
func intValue(byAdvancingPointer pointer: inout UnsafePointer<UInt8>?, length: Int? = nil) -> Int64? {
let length = length ?? self.length
pointer = pointer?.advanced(by: length)
guard let intValue = self.intValue else { return nil }
@@ -1,21 +1,21 @@
//
// OpenSSLWrappers.swift
// Hekate iOS
// AppReceiptValidator iOS
//
// Created by Hannes Oud on 07.09.17.
// Copyright © 2017 IdeasOnCanvas GmbH. All rights reserved.
//
import AppReceiptValidator.OpenSSL
import Foundation
import Hekate.OpenSSL
final class BIOWrapper {
let bio = BIO_new(BIO_s_mem())
init(data: Data) {
data.withUnsafeBytes { pointer -> Void in
BIO_write(self.bio, pointer, Int32(data.count))
_ = data.withUnsafeBytes { pointer in
BIO_write(self.bio, pointer.baseAddress, Int32(data.count))
}
}
@@ -207,13 +207,13 @@ typedef struct asn1_const_ctx_st {
# define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */
# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */
# define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */
typedef struct asn1_object_st {
struct asn1_object_st {
const char *sn, *ln;
int nid;
int length;
const unsigned char *data; /* data remains const after init */
int flags; /* Should we free this one */
} ASN1_OBJECT;
};
# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */
/*
@@ -843,7 +843,7 @@ int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
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);
@@ -853,13 +853,15 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
# endif
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
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);
@@ -174,6 +174,7 @@ extern "C" {
# 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
@@ -558,11 +559,11 @@ int BIO_read_filename(BIO *b, const char *name);
# 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);
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);
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);
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) */
@@ -688,7 +689,7 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
long argl, long ret);
BIO_METHOD *BIO_s_mem(void);
BIO *BIO_new_mem_buf(void *buf, int len);
BIO *BIO_new_mem_buf(const void *buf, int len);
BIO_METHOD *BIO_s_socket(void);
BIO_METHOD *BIO_s_connect(void);
BIO_METHOD *BIO_s_accept(void);
@@ -729,6 +730,9 @@ int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);
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);
struct hostent *BIO_gethostbyname(const char *name);
/*-
* We might want a thread-safe interface too:
@@ -765,8 +769,8 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b);
int BIO_dgram_sctp_msg_waiting(BIO *b);
# endif
BIO *BIO_new_fd(int fd, int close_flag);
BIO *BIO_new_connect(char *host_port);
BIO *BIO_new_accept(char *host_port);
BIO *BIO_new_connect(const char *host_port);
BIO *BIO_new_accept(const char *host_port);
int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
BIO **bio2, size_t writebuf2);
@@ -257,24 +257,6 @@ extern "C" {
# define BN_HEX_FMT2 "%08X"
# endif
/*
* 2011-02-22 SMS. In various places, a size_t variable or a type cast to
* size_t was used to perform integer-only operations on pointers. This
* failed on VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t
* is still only 32 bits. What's needed in these cases is an integer type
* with the same size as a pointer, which size_t is not certain to be. The
* only fix here is VMS-specific.
*/
# if defined(OPENSSL_SYS_VMS)
# if __INITIAL_POINTER_SIZE == 64
# define PTR_SIZE_INT long long
# else /* __INITIAL_POINTER_SIZE == 64 */
# define PTR_SIZE_INT int
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
# else /* defined(OPENSSL_SYS_VMS) */
# define PTR_SIZE_INT size_t
# endif /* defined(OPENSSL_SYS_VMS) [else] */
# define BN_DEFAULT_BITS 1280
# define BN_FLG_MALLOCED 0x01
@@ -860,6 +842,8 @@ int RAND_pseudo_bytes(unsigned char *buf, int num);
if (*(ftl--)) break; \
(a)->top = tmp_top; \
} \
if ((a)->top == 0) \
(a)->neg = 0; \
bn_pollute(a); \
}
@@ -84,6 +84,7 @@ BUF_MEM *BUF_MEM_new(void);
void BUF_MEM_free(BUF_MEM *a);
int BUF_MEM_grow(BUF_MEM *str, size_t len);
int BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
size_t BUF_strnlen(const char *str, size_t maxlen);
char *BUF_strdup(const char *str);
/*
@@ -72,9 +72,12 @@ 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;
DECLARE_STACK_OF(CMS_SignerInfo)
DECLARE_STACK_OF(GENERAL_NAMES)
DECLARE_STACK_OF(CMS_RecipientEncryptedKey)
DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)
DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
@@ -82,6 +85,7 @@ 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
@@ -111,6 +115,7 @@ DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
# define CMS_REUSE_DIGEST 0x8000
# define CMS_USE_KEYID 0x10000
# define CMS_DEBUG_DECRYPT 0x20000
# define CMS_KEY_PARAM 0x40000
const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);
@@ -189,6 +194,7 @@ int CMS_decrypt_set1_password(CMS_ContentInfo *cms,
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);
@@ -234,6 +240,7 @@ CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
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);
@@ -256,6 +263,8 @@ 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);
@@ -268,6 +277,7 @@ int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
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);
@@ -331,8 +341,37 @@ void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,
int *pallorfirst,
STACK_OF(GENERAL_NAMES) **plist,
STACK_OF(GENERAL_NAMES) **prto);
# endif
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);
/* BEGIN ERROR CODES */
/*
@@ -377,6 +416,7 @@ void ERR_load_CMS_strings(void);
# 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
@@ -388,6 +428,12 @@ void ERR_load_CMS_strings(void);
# 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
@@ -401,6 +447,9 @@ void ERR_load_CMS_strings(void);
# 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
@@ -452,6 +501,7 @@ void ERR_load_CMS_strings(void);
# 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
@@ -14,7 +14,7 @@ extern "C" {
typedef struct comp_ctx_st COMP_CTX;
typedef struct comp_method_st {
struct comp_method_st {
int type; /* NID for compression library */
const char *name; /* A text string to identify the library */
int (*init) (COMP_CTX *ctx);
@@ -30,7 +30,7 @@ typedef struct comp_method_st {
*/
long (*ctrl) (void);
long (*callback_ctrl) (void);
} COMP_METHOD;
};
struct comp_ctx_st {
COMP_METHOD *meth;
@@ -259,6 +259,7 @@ void ERR_load_CONF_strings(void);
# define CONF_R_NO_VALUE 108
# 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
#ifdef __cplusplus
@@ -628,7 +628,7 @@ void OPENSSL_init(void);
* into a defined order as the return value when a != b is undefined, other
* than to be non-zero.
*/
int CRYPTO_memcmp(const void *a, const void *b, size_t len);
int CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len);
/* BEGIN ERROR CODES */
/*
@@ -104,7 +104,7 @@
# endif
# ifdef _KERBEROS_DES_H
# error "des_old.h" replaces <kerberos/des.h>.
# error <openssl/des_old.h> replaces <kerberos/des.h>.
# endif
# include "symhacks.h"
@@ -142,7 +142,7 @@ struct dh_st {
BIGNUM *p;
BIGNUM *g;
long length; /* optional */
BIGNUM *pub_key; /* g^x */
BIGNUM *pub_key; /* g^x % p */
BIGNUM *priv_key; /* x */
int flags;
BN_MONT_CTX *method_mont_p;
@@ -167,10 +167,14 @@ struct dh_st {
# define DH_CHECK_P_NOT_SAFE_PRIME 0x02
# define DH_UNABLE_TO_CHECK_GENERATOR 0x04
# define DH_NOT_SUITABLE_GENERATOR 0x08
# define DH_CHECK_Q_NOT_PRIME 0x10
# define DH_CHECK_INVALID_Q_VALUE 0x20
# define DH_CHECK_INVALID_J_VALUE 0x40
/* DH_check_pub_key error codes */
# define DH_CHECK_PUBKEY_TOO_SMALL 0x01
# define DH_CHECK_PUBKEY_TOO_LARGE 0x02
# define DH_CHECK_PUBKEY_INVALID 0x04
/*
* primes p where (p-1)/2 is prime too are called "safe"; we define this for
@@ -178,12 +182,29 @@ struct dh_st {
*/
# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
# define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
(char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
# define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
(unsigned char *)(x))
# define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
# define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
# define d2i_DHparams_fp(fp,x) \
(DH *)ASN1_d2i_fp((char *(*)())DH_new, \
(char *(*)())d2i_DHparams, \
(fp), \
(unsigned char **)(x))
# define i2d_DHparams_fp(fp,x) \
ASN1_i2d_fp(i2d_DHparams,(fp), (unsigned char *)(x))
# define d2i_DHparams_bio(bp,x) \
ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x)
# define i2d_DHparams_bio(bp,x) \
ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
# define d2i_DHxparams_fp(fp,x) \
(DH *)ASN1_d2i_fp((char *(*)())DH_new, \
(char *(*)())d2i_DHxparams, \
(fp), \
(unsigned char **)(x))
# define i2d_DHxparams_fp(fp,x) \
ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x))
# define d2i_DHxparams_bio(bp,x) \
ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x)
# define i2d_DHxparams_bio(bp,x) \
ASN1_i2d_bio_of_const(DH, i2d_DHxparams, bp, x)
DH *DHparams_dup(DH *);
@@ -217,8 +238,11 @@ int DH_check(const DH *dh, int *codes);
int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);
int DH_generate_key(DH *dh);
int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);
DH *d2i_DHparams(DH **a, const unsigned char **pp, long length);
int i2d_DHparams(const DH *a, unsigned char **pp);
DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);
int i2d_DHxparams(const DH *a, unsigned char **pp);
# ifndef OPENSSL_NO_FP_API
int DHparams_print_fp(FILE *fp, const DH *x);
# endif
@@ -228,16 +252,111 @@ int DHparams_print(BIO *bp, const DH *x);
int DHparams_print(char *bp, const DH *x);
# endif
/* RFC 5114 parameters */
DH *DH_get_1024_160(void);
DH *DH_get_2048_224(void);
DH *DH_get_2048_256(void);
# ifndef OPENSSL_NO_CMS
/* RFC2631 KDF */
int DH_KDF_X9_42(unsigned char *out, size_t outlen,
const unsigned char *Z, size_t Zlen,
ASN1_OBJECT *key_oid,
const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);
# endif
# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)
# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)
# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)
# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)
# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)
# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)
# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid)
# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid)
# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md)
# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd)
# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)
# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen)
# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p)
# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p)
# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1)
# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2)
# define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3)
# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4)
# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5)
# define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6)
# define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7)
# define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8)
# define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9)
# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10)
# define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11)
# define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12)
# define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13)
# define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14)
/* KDF types */
# define EVP_PKEY_DH_KDF_NONE 1
# define EVP_PKEY_DH_KDF_X9_42 2
/* BEGIN ERROR CODES */
/*
@@ -252,6 +371,9 @@ void ERR_load_DH_strings(void);
# define DH_F_COMPUTE_KEY 102
# define DH_F_DHPARAMS_PRINT_FP 101
# define DH_F_DH_BUILTIN_GENPARAMS 106
# define DH_F_DH_CMS_DECRYPT 117
# define DH_F_DH_CMS_SET_PEERKEY 118
# define DH_F_DH_CMS_SET_SHARED_INFO 119
# define DH_F_DH_COMPUTE_KEY 114
# define DH_F_DH_GENERATE_KEY 115
# define DH_F_DH_GENERATE_PARAMETERS_EX 116
@@ -273,6 +395,7 @@ void ERR_load_DH_strings(void);
# define DH_R_BN_ERROR 106
# define DH_R_DECODE_ERROR 104
# define DH_R_INVALID_PUBKEY 102
# define DH_R_KDF_PARAMETER_ERROR 112
# define DH_R_KEYS_NOT_SET 108
# define DH_R_KEY_SIZE_TOO_SMALL 110
# define DH_R_MODULUS_TOO_LARGE 103
@@ -280,6 +403,8 @@ void ERR_load_DH_strings(void);
# define DH_R_NO_PARAMETERS_SET 107
# define DH_R_NO_PRIVATE_VALUE 100
# define DH_R_PARAMETER_ENCODING_ERROR 105
# define DH_R_PEER_KEY_ERROR 113
# define DH_R_SHARED_INFO_ERROR 114
#ifdef __cplusplus
}
@@ -287,6 +287,7 @@ void ERR_load_DSA_strings(void);
# define DSA_F_DO_DSA_PRINT 104
# define DSA_F_DSAPARAMS_PRINT 100
# define DSA_F_DSAPARAMS_PRINT_FP 101
# define DSA_F_DSA_BUILTIN_PARAMGEN2 126
# define DSA_F_DSA_DO_SIGN 112
# define DSA_F_DSA_DO_VERIFY 113
# define DSA_F_DSA_GENERATE_KEY 124
@@ -316,12 +317,14 @@ void ERR_load_DSA_strings(void);
# define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
# define DSA_R_DECODE_ERROR 104
# define DSA_R_INVALID_DIGEST_TYPE 106
# define DSA_R_INVALID_PARAMETERS 112
# define DSA_R_MISSING_PARAMETERS 101
# define DSA_R_MODULUS_TOO_LARGE 103
# define DSA_R_NEED_NEW_SETUP_VALUES 110
# define DSA_R_NON_FIPS_DSA_METHOD 111
# define DSA_R_NO_PARAMETERS_SET 107
# define DSA_R_PARAMETER_ENCODING_ERROR 105
# define DSA_R_Q_NOT_PRIME 113
#ifdef __cplusplus
}
@@ -84,11 +84,15 @@ extern "C" {
#endif
# define DTLS1_VERSION 0xFEFF
# define DTLS_MAX_VERSION DTLS1_VERSION
# define DTLS1_2_VERSION 0xFEFD
# define DTLS_MAX_VERSION DTLS1_2_VERSION
# define DTLS1_VERSION_MAJOR 0xFE
# define DTLS1_BAD_VER 0x0100
/* Special value for method supporting multiple versions */
# define DTLS_ANY_VERSION 0x1FFFF
# if 0
/* this alert description is not specified anywhere... */
# define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110
@@ -101,7 +101,7 @@ extern "C" {
# undef OPENSSL_SYS_UNIX
# define OPENSSL_SYS_WIN32_UWIN
# else
# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32)
# if defined(__CYGWIN__) || defined(OPENSSL_SYSNAME_CYGWIN)
# undef OPENSSL_SYS_UNIX
# define OPENSSL_SYS_WIN32_CYGWIN
# else
@@ -240,6 +240,12 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
*/
const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
/** Returns the montgomery data for order(Generator)
* \param group EC_GROUP object
* \return the currently used generator (possibly NULL).
*/
BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);
/** Gets the order of a EC_GROUP
* \param group EC_GROUP object
* \param order BIGNUM to which the order is copied
@@ -404,6 +410,9 @@ typedef struct {
*/
size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
const char *EC_curve_nid2nist(int nid);
int EC_curve_nist2nid(const char *name);
/********************************************************************/
/* EC_POINT functions */
/********************************************************************/
@@ -986,10 +995,78 @@ int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
# endif
# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)
# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)
# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)
# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)
# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)
# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)
# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)
# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)
# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)
# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)
# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)
# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
# define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2)
# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3)
# define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4)
# define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5)
# define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6)
# define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7)
# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8)
# define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9)
# define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10)
/* KDF types */
# define EVP_PKEY_ECDH_KDF_NONE 1
# define EVP_PKEY_ECDH_KDF_X9_62 2
/* BEGIN ERROR CODES */
/*
@@ -1007,6 +1084,8 @@ void ERR_load_EC_strings(void);
# define EC_F_D2I_ECPKPARAMETERS 145
# define EC_F_D2I_ECPRIVATEKEY 146
# define EC_F_DO_EC_KEY_PRINT 221
# define EC_F_ECDH_CMS_DECRYPT 238
# define EC_F_ECDH_CMS_SET_SHARED_INFO 239
# define EC_F_ECKEY_PARAM2TYPE 223
# define EC_F_ECKEY_PARAM_DECODE 212
# define EC_F_ECKEY_PRIV_DECODE 213
@@ -1018,6 +1097,12 @@ void ERR_load_EC_strings(void);
# define EC_F_ECPARAMETERS_PRINT_FP 148
# define EC_F_ECPKPARAMETERS_PRINT 149
# define EC_F_ECPKPARAMETERS_PRINT_FP 150
# define EC_F_ECP_NISTZ256_GET_AFFINE 240
# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243
# define EC_F_ECP_NISTZ256_POINTS_MUL 241
# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244
# define EC_F_ECP_NISTZ256_SET_WORDS 245
# define EC_F_ECP_NISTZ256_WINDOWED_MUL 242
# define EC_F_ECP_NIST_MOD_192 203
# define EC_F_ECP_NIST_MOD_224 204
# define EC_F_ECP_NIST_MOD_256 205
@@ -1157,6 +1242,7 @@ void ERR_load_EC_strings(void);
# define EC_R_INVALID_COMPRESSED_POINT 110
# define EC_R_INVALID_COMPRESSION_BIT 109
# define EC_R_INVALID_CURVE 141
# define EC_R_INVALID_DIGEST 151
# define EC_R_INVALID_DIGEST_TYPE 138
# define EC_R_INVALID_ENCODING 102
# define EC_R_INVALID_FIELD 103
@@ -1165,6 +1251,7 @@ void ERR_load_EC_strings(void);
# define EC_R_INVALID_PENTANOMIAL_BASIS 132
# define EC_R_INVALID_PRIVATE_KEY 123
# define EC_R_INVALID_TRINOMIAL_BASIS 137
# define EC_R_KDF_PARAMETER_ERROR 148
# define EC_R_KEYS_NOT_SET 140
# define EC_R_MISSING_PARAMETERS 124
# define EC_R_MISSING_PRIVATE_KEY 125
@@ -1175,9 +1262,11 @@ void ERR_load_EC_strings(void);
# define EC_R_NO_FIELD_MOD 133
# define EC_R_NO_PARAMETERS_SET 139
# define EC_R_PASSED_NULL_PARAMETER 134
# define EC_R_PEER_KEY_ERROR 149
# define EC_R_PKPARAMETERS2GROUP_FAILURE 127
# define EC_R_POINT_AT_INFINITY 106
# define EC_R_POINT_IS_NOT_ON_CURVE 107
# define EC_R_SHARED_INFO_ERROR 150
# define EC_R_SLOT_FULL 108
# define EC_R_UNDEFINED_GENERATOR 113
# define EC_R_UNDEFINED_ORDER 128
@@ -85,6 +85,8 @@
extern "C" {
#endif
# define EC_FLAG_COFACTOR_ECDH 0x1000
const ECDH_METHOD *ECDH_OpenSSL(void);
void ECDH_set_default_method(const ECDH_METHOD *);
@@ -101,6 +103,11 @@ int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);
void *ECDH_get_ex_data(EC_KEY *d, int idx);
int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
const unsigned char *Z, size_t Zlen,
const unsigned char *sinfo, size_t sinfolen,
const EVP_MD *md);
/* BEGIN ERROR CODES */
/*
* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -228,6 +228,80 @@ int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);
void *ECDSA_get_ex_data(EC_KEY *d, int idx);
/** Allocates and initialize a ECDSA_METHOD structure
* \param ecdsa_method pointer to ECDSA_METHOD to copy. (May be NULL)
* \return pointer to a ECDSA_METHOD structure or NULL if an error occurred
*/
ECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_method);
/** frees a ECDSA_METHOD structure
* \param ecdsa_method pointer to the ECDSA_METHOD structure
*/
void ECDSA_METHOD_free(ECDSA_METHOD *ecdsa_method);
/** Sets application specific data in the ECDSA_METHOD
* \param ecdsa_method pointer to existing ECDSA_METHOD
* \param app application specific data to set
*/
void ECDSA_METHOD_set_app_data(ECDSA_METHOD *ecdsa_method, void *app);
/** Returns application specific data from a ECDSA_METHOD structure
* \param ecdsa_method pointer to ECDSA_METHOD structure
* \return pointer to application specific data.
*/
void *ECDSA_METHOD_get_app_data(ECDSA_METHOD *ecdsa_method);
/** Set the ECDSA_do_sign function in the ECDSA_METHOD
* \param ecdsa_method pointer to existing ECDSA_METHOD
* \param ecdsa_do_sign a funtion of type ECDSA_do_sign
*/
void ECDSA_METHOD_set_sign(ECDSA_METHOD *ecdsa_method,
ECDSA_SIG *(*ecdsa_do_sign) (const unsigned char
*dgst, int dgst_len,
const BIGNUM *inv,
const BIGNUM *rp,
EC_KEY *eckey));
/** Set the ECDSA_sign_setup function in the ECDSA_METHOD
* \param ecdsa_method pointer to existing ECDSA_METHOD
* \param ecdsa_sign_setup a funtion of type ECDSA_sign_setup
*/
void ECDSA_METHOD_set_sign_setup(ECDSA_METHOD *ecdsa_method,
int (*ecdsa_sign_setup) (EC_KEY *eckey,
BN_CTX *ctx,
BIGNUM **kinv,
BIGNUM **r));
/** Set the ECDSA_do_verify function in the ECDSA_METHOD
* \param ecdsa_method pointer to existing ECDSA_METHOD
* \param ecdsa_do_verify a funtion of type ECDSA_do_verify
*/
void ECDSA_METHOD_set_verify(ECDSA_METHOD *ecdsa_method,
int (*ecdsa_do_verify) (const unsigned char
*dgst, int dgst_len,
const ECDSA_SIG *sig,
EC_KEY *eckey));
void ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags);
/** Set the flags field in the ECDSA_METHOD
* \param ecdsa_method pointer to existing ECDSA_METHOD
* \param flags flags value to set
*/
void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name);
/** Set the name field in the ECDSA_METHOD
* \param ecdsa_method pointer to existing ECDSA_METHOD
* \param name name to set
*/
/* BEGIN ERROR CODES */
/*
* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -242,6 +316,7 @@ void ERR_load_ECDSA_strings(void);
# define ECDSA_F_ECDSA_DATA_NEW_METHOD 100
# define ECDSA_F_ECDSA_DO_SIGN 101
# define ECDSA_F_ECDSA_DO_VERIFY 102
# define ECDSA_F_ECDSA_METHOD_NEW 105
# define ECDSA_F_ECDSA_SIGN_SETUP 103
/* Reason codes. */
@@ -413,7 +413,6 @@ void ENGINE_load_gost(void);
# endif
# endif
void ENGINE_load_cryptodev(void);
void ENGINE_load_rsax(void);
void ENGINE_load_rdrand(void);
void ENGINE_load_builtin_engines(void);
@@ -258,6 +258,7 @@ typedef struct err_state_st {
# define SYS_F_WSASTARTUP 9/* Winsock stuff */
# define SYS_F_OPENDIR 10
# define SYS_F_FREAD 11
# define SYS_F_FFLUSH 18
/* reasons */
# define ERR_R_SYS_LIB ERR_LIB_SYS/* 2 */
@@ -113,6 +113,7 @@
# define EVP_PKEY_DSA3 NID_dsaWithSHA1
# define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
# define EVP_PKEY_DH NID_dhKeyAgreement
# define EVP_PKEY_DHX NID_dhpublicnumber
# define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
# define EVP_PKEY_HMAC NID_hmac
# define EVP_PKEY_CMAC NID_cmac
@@ -345,6 +346,7 @@ struct evp_cipher_st {
# define EVP_CIPH_GCM_MODE 0x6
# define EVP_CIPH_CCM_MODE 0x7
# define EVP_CIPH_XTS_MODE 0x10001
# define EVP_CIPH_WRAP_MODE 0x10002
# define EVP_CIPH_MODE 0xF0007
/* Set if variable length cipher */
# define EVP_CIPH_VARIABLE_LENGTH 0x8
@@ -375,6 +377,14 @@ struct evp_cipher_st {
*/
# define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000
# define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000
# define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000
/*
* Cipher context flag to indicate we can handle wrap mode: if allowed in
* older applications it could overflow buffers.
*/
# define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1
/* ctrl() values */
@@ -408,9 +418,21 @@ struct evp_cipher_st {
/* Set the GCM invocation field, decrypt only */
# define EVP_CTRL_GCM_SET_IV_INV 0x18
# define EVP_CTRL_TLS1_1_MULTIBLOCK_AAD 0x19
# define EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT 0x1a
# define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b
# define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c
/* RFC 5246 defines additional data to be 13 bytes in length */
# define EVP_AEAD_TLS1_AAD_LEN 13
typedef struct {
unsigned char *out;
const unsigned char *inp;
size_t len;
unsigned int interleave;
} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;
/* GCM TLS constants */
/* Length of fixed part of IV derived from PRF */
# define EVP_GCM_TLS_FIXED_IV_LEN 4
@@ -639,7 +661,8 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx,
int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen);
int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,
const unsigned char *sig, size_t siglen);
int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
const unsigned char *ek, int ekl, const unsigned char *iv,
@@ -744,6 +767,7 @@ const EVP_CIPHER *EVP_des_cbc(void);
const EVP_CIPHER *EVP_des_ede_cbc(void);
const EVP_CIPHER *EVP_des_ede3_cbc(void);
const EVP_CIPHER *EVP_desx_cbc(void);
const EVP_CIPHER *EVP_des_ede3_wrap(void);
/*
* This should now be supported through the dev_crypto ENGINE. But also, why
* are rc4 and md5 declarations made here inside a "NO_DES" precompiler
@@ -813,6 +837,7 @@ const EVP_CIPHER *EVP_aes_128_ctr(void);
const EVP_CIPHER *EVP_aes_128_ccm(void);
const EVP_CIPHER *EVP_aes_128_gcm(void);
const EVP_CIPHER *EVP_aes_128_xts(void);
const EVP_CIPHER *EVP_aes_128_wrap(void);
const EVP_CIPHER *EVP_aes_192_ecb(void);
const EVP_CIPHER *EVP_aes_192_cbc(void);
const EVP_CIPHER *EVP_aes_192_cfb1(void);
@@ -823,6 +848,7 @@ const EVP_CIPHER *EVP_aes_192_ofb(void);
const EVP_CIPHER *EVP_aes_192_ctr(void);
const EVP_CIPHER *EVP_aes_192_ccm(void);
const EVP_CIPHER *EVP_aes_192_gcm(void);
const EVP_CIPHER *EVP_aes_192_wrap(void);
const EVP_CIPHER *EVP_aes_256_ecb(void);
const EVP_CIPHER *EVP_aes_256_cbc(void);
const EVP_CIPHER *EVP_aes_256_cfb1(void);
@@ -834,10 +860,15 @@ const EVP_CIPHER *EVP_aes_256_ctr(void);
const EVP_CIPHER *EVP_aes_256_ccm(void);
const EVP_CIPHER *EVP_aes_256_gcm(void);
const EVP_CIPHER *EVP_aes_256_xts(void);
const EVP_CIPHER *EVP_aes_256_wrap(void);
# if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
# endif
# ifndef OPENSSL_NO_SHA256
const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);
const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);
# endif
# endif
# ifndef OPENSSL_NO_CAMELLIA
const EVP_CIPHER *EVP_camellia_128_ecb(void);
@@ -1028,6 +1059,7 @@ void EVP_PBE_cleanup(void);
# define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3
# define ASN1_PKEY_CTRL_CMS_SIGN 0x5
# define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7
# define ASN1_PKEY_CTRL_CMS_RI_TYPE 0x8
int EVP_PKEY_asn1_get_count(void);
const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
@@ -1091,6 +1123,19 @@ void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
int (*pkey_ctrl) (EVP_PKEY *pkey, int op,
long arg1, void *arg2));
void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,
int (*item_verify) (EVP_MD_CTX *ctx,
const ASN1_ITEM *it,
void *asn,
X509_ALGOR *a,
ASN1_BIT_STRING *sig,
EVP_PKEY *pkey),
int (*item_sign) (EVP_MD_CTX *ctx,
const ASN1_ITEM *it,
void *asn,
X509_ALGOR *alg1,
X509_ALGOR *alg2,
ASN1_BIT_STRING *sig));
# define EVP_PKEY_OP_UNDEFINED 0
# define EVP_PKEY_OP_PARAMGEN (1<<1)
@@ -1121,6 +1166,10 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
EVP_PKEY_CTRL_MD, 0, (void *)md)
# define EVP_PKEY_CTX_get_signature_md(ctx, pmd) \
EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
EVP_PKEY_CTRL_GET_MD, 0, (void *)pmd)
# define EVP_PKEY_CTRL_MD 1
# define EVP_PKEY_CTRL_PEER_KEY 2
@@ -1142,6 +1191,8 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
# define EVP_PKEY_CTRL_CIPHER 12
# define EVP_PKEY_CTRL_GET_MD 13
# define EVP_PKEY_ALG_CTRL 0x1000
# define EVP_PKEY_FLAG_AUTOARGLEN 2
@@ -1312,6 +1363,98 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
const char *type,
const char *value));
void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth,
int (**pinit) (EVP_PKEY_CTX *ctx));
void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth,
int (**pcopy) (EVP_PKEY_CTX *dst,
EVP_PKEY_CTX *src));
void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth,
void (**pcleanup) (EVP_PKEY_CTX *ctx));
void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth,
int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
int (**pparamgen) (EVP_PKEY_CTX *ctx,
EVP_PKEY *pkey));
void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth,
int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
int (**pkeygen) (EVP_PKEY_CTX *ctx,
EVP_PKEY *pkey));
void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth,
int (**psign_init) (EVP_PKEY_CTX *ctx),
int (**psign) (EVP_PKEY_CTX *ctx,
unsigned char *sig, size_t *siglen,
const unsigned char *tbs,
size_t tbslen));
void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth,
int (**pverify_init) (EVP_PKEY_CTX *ctx),
int (**pverify) (EVP_PKEY_CTX *ctx,
const unsigned char *sig,
size_t siglen,
const unsigned char *tbs,
size_t tbslen));
void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth,
int (**pverify_recover_init) (EVP_PKEY_CTX
*ctx),
int (**pverify_recover) (EVP_PKEY_CTX
*ctx,
unsigned char
*sig,
size_t *siglen,
const unsigned
char *tbs,
size_t tbslen));
void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth,
int (**psignctx_init) (EVP_PKEY_CTX *ctx,
EVP_MD_CTX *mctx),
int (**psignctx) (EVP_PKEY_CTX *ctx,
unsigned char *sig,
size_t *siglen,
EVP_MD_CTX *mctx));
void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth,
int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
EVP_MD_CTX *mctx),
int (**pverifyctx) (EVP_PKEY_CTX *ctx,
const unsigned char *sig,
int siglen,
EVP_MD_CTX *mctx));
void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth,
int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
int (**pencryptfn) (EVP_PKEY_CTX *ctx,
unsigned char *out,
size_t *outlen,
const unsigned char *in,
size_t inlen));
void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth,
int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
int (**pdecrypt) (EVP_PKEY_CTX *ctx,
unsigned char *out,
size_t *outlen,
const unsigned char *in,
size_t inlen));
void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth,
int (**pderive_init) (EVP_PKEY_CTX *ctx),
int (**pderive) (EVP_PKEY_CTX *ctx,
unsigned char *key,
size_t *keylen));
void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth,
int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
void *p2),
int (**pctrl_str) (EVP_PKEY_CTX *ctx,
const char *type,
const char *value));
void EVP_add_alg_module(void);
/* BEGIN ERROR CODES */
@@ -1319,6 +1462,7 @@ void EVP_add_alg_module(void);
* The following lines are auto generated by the script mkerr.pl. Any changes
* made after this point may be overwritten when the script is next run.
*/
void ERR_load_EVP_strings(void);
/* Error codes for the EVP functions. */
@@ -1327,11 +1471,13 @@ void ERR_load_EVP_strings(void);
# define EVP_F_AESNI_INIT_KEY 165
# define EVP_F_AESNI_XTS_CIPHER 176
# define EVP_F_AES_INIT_KEY 133
# define EVP_F_AES_T4_INIT_KEY 178
# define EVP_F_AES_XTS 172
# define EVP_F_AES_XTS_CIPHER 175
# define EVP_F_ALG_MODULE_INIT 177
# define EVP_F_CAMELLIA_INIT_KEY 159
# define EVP_F_CMAC_INIT 173
# define EVP_F_CMLL_T4_INIT_KEY 179
# define EVP_F_D2I_PKEY 100
# define EVP_F_DO_SIGVER_INIT 161
# define EVP_F_DSAPKEY2PKCS8 134
@@ -1436,6 +1582,7 @@ void ERR_load_EVP_strings(void);
# define EVP_R_INPUT_NOT_INITIALIZED 111
# define EVP_R_INVALID_DIGEST 152
# define EVP_R_INVALID_FIPS_MODE 168
# define EVP_R_INVALID_KEY 171
# define EVP_R_INVALID_KEY_LENGTH 130
# define EVP_R_INVALID_OPERATION 148
# define EVP_R_IV_TOO_LARGE 102
@@ -1471,10 +1618,11 @@ void ERR_load_EVP_strings(void);
# define EVP_R_UNSUPPORTED_PRF 125
# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118
# define EVP_R_UNSUPPORTED_SALT_TYPE 126
# define EVP_R_WRAP_MODE_NOT_ALLOWED 170
# define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
# define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
#ifdef __cplusplus
# ifdef __cplusplus
}
#endif
# endif
#endif
@@ -148,6 +148,16 @@ int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,
const unsigned char *inp, unsigned char *out,
size_t len, int enc);
size_t CRYPTO_128_wrap(void *key, const unsigned char *iv,
unsigned char *out,
const unsigned char *in, size_t inlen,
block128_f block);
size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,
unsigned char *out,
const unsigned char *in, size_t inlen,
block128_f block);
#ifdef __cplusplus
}
#endif
@@ -590,6 +590,11 @@
#define NID_mgf1 911
#define OBJ_mgf1 OBJ_pkcs1,8L
#define SN_pSpecified "PSPECIFIED"
#define LN_pSpecified "pSpecified"
#define NID_pSpecified 935
#define OBJ_pSpecified OBJ_pkcs1,9L
#define SN_rsassaPss "RSASSA-PSS"
#define LN_rsassaPss "rsassaPss"
#define NID_rsassaPss 912
@@ -4029,3 +4034,161 @@
#define SN_aes_256_cbc_hmac_sha1 "AES-256-CBC-HMAC-SHA1"
#define LN_aes_256_cbc_hmac_sha1 "aes-256-cbc-hmac-sha1"
#define NID_aes_256_cbc_hmac_sha1 918
#define SN_aes_128_cbc_hmac_sha256 "AES-128-CBC-HMAC-SHA256"
#define LN_aes_128_cbc_hmac_sha256 "aes-128-cbc-hmac-sha256"
#define NID_aes_128_cbc_hmac_sha256 948
#define SN_aes_192_cbc_hmac_sha256 "AES-192-CBC-HMAC-SHA256"
#define LN_aes_192_cbc_hmac_sha256 "aes-192-cbc-hmac-sha256"
#define NID_aes_192_cbc_hmac_sha256 949
#define SN_aes_256_cbc_hmac_sha256 "AES-256-CBC-HMAC-SHA256"
#define LN_aes_256_cbc_hmac_sha256 "aes-256-cbc-hmac-sha256"
#define NID_aes_256_cbc_hmac_sha256 950
#define SN_dhpublicnumber "dhpublicnumber"
#define LN_dhpublicnumber "X9.42 DH"
#define NID_dhpublicnumber 920
#define OBJ_dhpublicnumber OBJ_ISO_US,10046L,2L,1L
#define SN_brainpoolP160r1 "brainpoolP160r1"
#define NID_brainpoolP160r1 921
#define OBJ_brainpoolP160r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,1L
#define SN_brainpoolP160t1 "brainpoolP160t1"
#define NID_brainpoolP160t1 922
#define OBJ_brainpoolP160t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,2L
#define SN_brainpoolP192r1 "brainpoolP192r1"
#define NID_brainpoolP192r1 923
#define OBJ_brainpoolP192r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,3L
#define SN_brainpoolP192t1 "brainpoolP192t1"
#define NID_brainpoolP192t1 924
#define OBJ_brainpoolP192t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,4L
#define SN_brainpoolP224r1 "brainpoolP224r1"
#define NID_brainpoolP224r1 925
#define OBJ_brainpoolP224r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,5L
#define SN_brainpoolP224t1 "brainpoolP224t1"
#define NID_brainpoolP224t1 926
#define OBJ_brainpoolP224t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,6L
#define SN_brainpoolP256r1 "brainpoolP256r1"
#define NID_brainpoolP256r1 927
#define OBJ_brainpoolP256r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,7L
#define SN_brainpoolP256t1 "brainpoolP256t1"
#define NID_brainpoolP256t1 928
#define OBJ_brainpoolP256t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,8L
#define SN_brainpoolP320r1 "brainpoolP320r1"
#define NID_brainpoolP320r1 929
#define OBJ_brainpoolP320r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,9L
#define SN_brainpoolP320t1 "brainpoolP320t1"
#define NID_brainpoolP320t1 930
#define OBJ_brainpoolP320t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,10L
#define SN_brainpoolP384r1 "brainpoolP384r1"
#define NID_brainpoolP384r1 931
#define OBJ_brainpoolP384r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,11L
#define SN_brainpoolP384t1 "brainpoolP384t1"
#define NID_brainpoolP384t1 932
#define OBJ_brainpoolP384t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,12L
#define SN_brainpoolP512r1 "brainpoolP512r1"
#define NID_brainpoolP512r1 933
#define OBJ_brainpoolP512r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,13L
#define SN_brainpoolP512t1 "brainpoolP512t1"
#define NID_brainpoolP512t1 934
#define OBJ_brainpoolP512t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,14L
#define OBJ_x9_63_scheme 1L,3L,133L,16L,840L,63L,0L
#define OBJ_secg_scheme OBJ_certicom_arc,1L
#define SN_dhSinglePass_stdDH_sha1kdf_scheme "dhSinglePass-stdDH-sha1kdf-scheme"
#define NID_dhSinglePass_stdDH_sha1kdf_scheme 936
#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme OBJ_x9_63_scheme,2L
#define SN_dhSinglePass_stdDH_sha224kdf_scheme "dhSinglePass-stdDH-sha224kdf-scheme"
#define NID_dhSinglePass_stdDH_sha224kdf_scheme 937
#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme OBJ_secg_scheme,11L,0L
#define SN_dhSinglePass_stdDH_sha256kdf_scheme "dhSinglePass-stdDH-sha256kdf-scheme"
#define NID_dhSinglePass_stdDH_sha256kdf_scheme 938
#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme OBJ_secg_scheme,11L,1L
#define SN_dhSinglePass_stdDH_sha384kdf_scheme "dhSinglePass-stdDH-sha384kdf-scheme"
#define NID_dhSinglePass_stdDH_sha384kdf_scheme 939
#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme OBJ_secg_scheme,11L,2L
#define SN_dhSinglePass_stdDH_sha512kdf_scheme "dhSinglePass-stdDH-sha512kdf-scheme"
#define NID_dhSinglePass_stdDH_sha512kdf_scheme 940
#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme OBJ_secg_scheme,11L,3L
#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme "dhSinglePass-cofactorDH-sha1kdf-scheme"
#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme 941
#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme OBJ_x9_63_scheme,3L
#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme "dhSinglePass-cofactorDH-sha224kdf-scheme"
#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme 942
#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme OBJ_secg_scheme,14L,0L
#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme "dhSinglePass-cofactorDH-sha256kdf-scheme"
#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme 943
#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme OBJ_secg_scheme,14L,1L
#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme "dhSinglePass-cofactorDH-sha384kdf-scheme"
#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme 944
#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme OBJ_secg_scheme,14L,2L
#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme "dhSinglePass-cofactorDH-sha512kdf-scheme"
#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme 945
#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme OBJ_secg_scheme,14L,3L
#define SN_dh_std_kdf "dh-std-kdf"
#define NID_dh_std_kdf 946
#define SN_dh_cofactor_kdf "dh-cofactor-kdf"
#define NID_dh_cofactor_kdf 947
#define SN_ct_precert_scts "ct_precert_scts"
#define LN_ct_precert_scts "CT Precertificate SCTs"
#define NID_ct_precert_scts 951
#define OBJ_ct_precert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L
#define SN_ct_precert_poison "ct_precert_poison"
#define LN_ct_precert_poison "CT Precertificate Poison"
#define NID_ct_precert_poison 952
#define OBJ_ct_precert_poison 1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L
#define SN_ct_precert_signer "ct_precert_signer"
#define LN_ct_precert_signer "CT Precertificate Signer"
#define NID_ct_precert_signer 953
#define OBJ_ct_precert_signer 1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L
#define SN_ct_cert_scts "ct_cert_scts"
#define LN_ct_cert_scts "CT Certificate SCTs"
#define NID_ct_cert_scts 954
#define OBJ_ct_cert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L
#define SN_jurisdictionLocalityName "jurisdictionL"
#define LN_jurisdictionLocalityName "jurisdictionLocalityName"
#define NID_jurisdictionLocalityName 955
#define OBJ_jurisdictionLocalityName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L
#define SN_jurisdictionStateOrProvinceName "jurisdictionST"
#define LN_jurisdictionStateOrProvinceName "jurisdictionStateOrProvinceName"
#define NID_jurisdictionStateOrProvinceName 956
#define OBJ_jurisdictionStateOrProvinceName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L
#define SN_jurisdictionCountryName "jurisdictionC"
#define LN_jurisdictionCountryName "jurisdictionCountryName"
#define NID_jurisdictionCountryName 957
#define OBJ_jurisdictionCountryName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L
@@ -394,11 +394,22 @@ typedef struct ocsp_service_locator_st {
OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);
OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,
int maxline);
int OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);
int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);
void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
void OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);
int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
ASN1_VALUE *val);
int OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,
const ASN1_ITEM *it);
BIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);
int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
ASN1_VALUE *val);
int OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);
int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
const char *name, const char *value);
@@ -447,7 +458,7 @@ int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
X509_STORE *store, unsigned long flags);
int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath,
int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
int *pssl);
int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
@@ -23,6 +23,9 @@ extern "C" {
#ifndef OPENSSL_NO_KRB5
# define OPENSSL_NO_KRB5
#endif
#ifndef OPENSSL_NO_LIBUNBOUND
# define OPENSSL_NO_LIBUNBOUND
#endif
#ifndef OPENSSL_NO_MD2
# define OPENSSL_NO_MD2
#endif
@@ -35,6 +38,9 @@ extern "C" {
#ifndef OPENSSL_NO_SCTP
# define OPENSSL_NO_SCTP
#endif
#ifndef OPENSSL_NO_SSL_TRACE
# define OPENSSL_NO_SSL_TRACE
#endif
#ifndef OPENSSL_NO_SSL2
# define OPENSSL_NO_SSL2
#endif
@@ -77,6 +83,9 @@ extern "C" {
# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)
# define NO_KRB5
# endif
# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND)
# define NO_LIBUNBOUND
# endif
# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2)
# define NO_MD2
# endif
@@ -89,6 +98,9 @@ extern "C" {
# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP)
# define NO_SCTP
# endif
# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE)
# define NO_SSL_TRACE
# endif
# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2)
# define NO_SSL2
# endif
@@ -110,8 +122,8 @@ extern "C" {
#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
#define ENGINESDIR "/tmp/openssl-1.0.1u-arm64/lib/engines"
#define OPENSSLDIR "/tmp/openssl-1.0.1u-arm64"
#define ENGINESDIR "/tmp/openssl-1.0.2n-arm64/lib/engines"
#define OPENSSLDIR "/tmp/openssl-1.0.2n-arm64"
#endif
#endif
@@ -30,11 +30,11 @@ extern "C" {
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x1000115fL
# define OPENSSL_VERSION_NUMBER 0x100020efL
# ifdef OPENSSL_FIPS
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1u-fips 22 Sep 2016"
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2n-fips 7 Dec 2017"
# else
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1u 22 Sep 2016"
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2n 7 Dec 2017"
# endif
# define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
@@ -100,6 +100,8 @@ typedef int ASN1_BOOLEAN;
typedef int ASN1_NULL;
# endif
typedef struct asn1_object_st ASN1_OBJECT;
typedef struct ASN1_ITEM_st ASN1_ITEM;
typedef struct asn1_pctx_st ASN1_PCTX;
@@ -176,6 +178,8 @@ typedef struct engine_st ENGINE;
typedef struct ssl_st SSL;
typedef struct ssl_ctx_st SSL_CTX;
typedef struct comp_method_st COMP_METHOD;
typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
@@ -129,6 +129,7 @@ extern "C" {
# define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
# define PEM_STRING_PKCS8INF "PRIVATE KEY"
# define PEM_STRING_DHPARAMS "DH PARAMETERS"
# define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS"
# define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
# define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
# define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
@@ -181,7 +182,6 @@ typedef struct pem_ctx_st {
int num_recipient;
PEM_USER **recipient;
/*-
XXX(ben): don#t think this is used!
STACK *x509_chain; / * certificate chain */
@@ -399,8 +399,8 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
# ifndef OPENSSL_NO_BIO
int PEM_read_bio(BIO *bp, char **name, char **header,
unsigned char **data, long *len);
int PEM_write_bio(BIO *bp, const char *name, char *hdr, unsigned char *data,
long len);
int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
const unsigned char *data, long len);
int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
const char *name, BIO *bp, pem_password_cb *cb,
void *u);
@@ -419,7 +419,8 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
int PEM_read(FILE *fp, char **name, char **header,
unsigned char **data, long *len);
int PEM_write(FILE *fp, char *name, char *hdr, unsigned char *data, long len);
int PEM_write(FILE *fp, const char *name, const char *hdr,
const unsigned char *data, long len);
void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
pem_password_cb *cb, void *u);
int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
@@ -474,6 +475,7 @@ DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
# endif
# ifndef OPENSSL_NO_DH
DECLARE_PEM_rw_const(DHparams, DH)
DECLARE_PEM_write_const(DHxparams, DH)
# endif
DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
@@ -529,6 +531,7 @@ int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
* The following lines are auto generated by the script mkerr.pl. Any changes
* made after this point may be overwritten when the script is next run.
*/
void ERR_load_PEM_strings(void);
/* Error codes for the PEM functions. */
@@ -562,8 +565,10 @@ void ERR_load_PEM_strings(void);
# define PEM_F_PEM_PK8PKEY 119
# define PEM_F_PEM_READ 108
# define PEM_F_PEM_READ_BIO 109
# define PEM_F_PEM_READ_BIO_DHPARAMS 141
# define PEM_F_PEM_READ_BIO_PARAMETERS 140
# define PEM_F_PEM_READ_BIO_PRIVATEKEY 123
# define PEM_F_PEM_READ_DHPARAMS 142
# define PEM_F_PEM_READ_PRIVATEKEY 124
# define PEM_F_PEM_SEALFINAL 110
# define PEM_F_PEM_SEALINIT 111
@@ -606,7 +611,7 @@ void ERR_load_PEM_strings(void);
# define PEM_R_UNSUPPORTED_ENCRYPTION 114
# define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126
#ifdef __cplusplus
# ifdef __cplusplus
}
#endif
# endif
#endif

Some files were not shown because too many files have changed in this diff Show More