forked from tink-crypto/tink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
objc: Implementation of hybrid key templates.
PiperOrigin-RevId: 196880687 GitOrigin-RevId: 2dcc7441d189d63b6ea1763fbdfdc267357af67b
- Loading branch information
Showing
17 changed files
with
757 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright 2017 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
************************************************************************** | ||
*/ | ||
|
||
#import "objc/hybrid/TINKHybridKeyTemplate.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright 2018 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
************************************************************************** | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* Wrapper class that holds key template options that are used to generate keysets. | ||
* This is the base/parent class that is subclassed by all the TINKXYZKeyTemplate classes. | ||
* | ||
* To create an instance of this class you need to use one of the subclasses: TINKAeadKeyTemplate, | ||
* TINKHybridKeyTemplate etc. | ||
*/ | ||
@interface TINKKeyTemplate : NSObject | ||
|
||
/** | ||
* This class is not meant to be instantiated directly; instead use one of the subclasses | ||
* (TINKAeadKeyTemplate, TINKHybridKeyTemplate etc.) to get an instance. | ||
*/ | ||
- (nullable instancetype)init NS_UNAVAILABLE; | ||
|
||
- (nullable instancetype)initWithKeyTemplate:(id)keyTemplate error:(NSError **)error; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2018 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
************************************************************************** | ||
*/ | ||
|
||
#import "objc/TINKKeyTemplate.h" | ||
#import "objc/core/TINKKeyTemplate_Internal.h" | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#include "tink/util/status.h" | ||
|
||
@interface TINKKeyTemplateTest : XCTestCase | ||
@end | ||
|
||
@implementation TINKKeyTemplateTest | ||
|
||
- (void)testInitialization { | ||
// Verify that the users can't initialize this class directly. | ||
NSError *error = nil; | ||
@try { | ||
TINKKeyTemplate *tpl = | ||
[[TINKKeyTemplate alloc] initWithKeyTemplate:[[NSObject alloc] init] error:&error]; | ||
XCTAssertNil(tpl); | ||
XCTAssertNotNil(error); | ||
XCTAssertEqual(error.code, crypto::tink::util::error::INTERNAL); | ||
XCTAssertTrue( | ||
[error.localizedFailureReason containsString:@"Only instantiate from derived classes!"]); | ||
} @catch (NSException *exception) { | ||
XCTAssertTrue([exception.reason isEqualToString:@"Only instantiate from derived classes!"]); | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.