Skip to content

Commit

Permalink
Removing deprecated Obj-C Tink APIs.
Browse files Browse the repository at this point in the history
NoExternal

PiperOrigin-RevId: 204765216
GitOrigin-RevId: 7f20929c10b907bd272219a27d6ee55487654283
  • Loading branch information
tl0gic authored and chuckx committed Jul 16, 2018
1 parent e76fa74 commit 627d621
Show file tree
Hide file tree
Showing 17 changed files with 13 additions and 210 deletions.
15 changes: 0 additions & 15 deletions objc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ PUBLIC_APIS = [
"TINKRegistryConfig.h",
"TINKSignatureConfig.h",
"TINKSignatureKeyTemplate.h",
"TINKVersion.h",
]

PUBLIC_API_DEPS = [
Expand Down Expand Up @@ -67,7 +66,6 @@ PUBLIC_API_DEPS = [
":registry_config",
":signature_config",
":signature_key_template",
":version",
"//objc/util:errors",
"//objc/util:strings",
]
Expand Down Expand Up @@ -116,7 +114,6 @@ objc_library(
],
deps = [
":registry_config",
":version",
"//cc/config:tink_config",
"//cc/util:errors",
"//objc/util:errors",
Expand Down Expand Up @@ -243,14 +240,6 @@ objc_library(
],
deps = [
":config_cc_pb",
":version",
],
)

objc_library(
name = "version",
hdrs = [
"TINKVersion.h",
],
)

Expand Down Expand Up @@ -282,7 +271,6 @@ objc_library(
hdrs = ["TINKAeadConfig.h"],
deps = [
":registry_config",
":version",
"//cc/aead:aead_config",
"//cc/util:errors",
"//objc/util:errors",
Expand Down Expand Up @@ -398,7 +386,6 @@ objc_library(
hdrs = ["TINKHybridConfig.h"],
deps = [
":registry_config",
":version",
"//cc/hybrid:hybrid_config",
"//cc/util:errors",
"//objc/util:errors",
Expand Down Expand Up @@ -436,7 +423,6 @@ objc_library(
hdrs = ["TINKMacConfig.h"],
deps = [
":registry_config",
":version",
"//cc/mac:mac_config",
"//cc/util:errors",
"//objc/util:errors",
Expand Down Expand Up @@ -526,7 +512,6 @@ objc_library(
hdrs = ["TINKSignatureConfig.h"],
deps = [
":registry_config",
":version",
"//cc/signature:signature_config",
"//cc/util:errors",
"//objc/util:errors",
Expand Down
9 changes: 0 additions & 9 deletions objc/TINKAeadConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import <Foundation/Foundation.h>

#import "TINKRegistryConfig.h"
#import "TINKVersion.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -49,14 +48,6 @@ NS_ASSUME_NONNULL_BEGIN
/* Returns config of Aead implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;

/**
* Returns config of Aead implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;

@end

NS_ASSUME_NONNULL_END
9 changes: 0 additions & 9 deletions objc/TINKAllConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import <Foundation/Foundation.h>

#import "TINKRegistryConfig.h"
#import "TINKVersion.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -46,14 +45,6 @@ NS_ASSUME_NONNULL_BEGIN
/** Returns config of all implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;

/**
* Returns config of all implementations supported in a given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;

@end

NS_ASSUME_NONNULL_END
11 changes: 1 addition & 10 deletions objc/TINKHybridConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import <Foundation/Foundation.h>

#import "TINKRegistryConfig.h"
#import "TINKVersion.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -44,20 +43,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface TINKHybridConfig : TINKRegistryConfig

/* Use initWithVersion:error: to get an instance of TINKHybridConfig. */
/* Use initWithError: to get an instance of TINKHybridConfig. */
- (nullable instancetype)init NS_UNAVAILABLE;

/* Returns config of Hybrid implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;

/**
* Returns config of Hybrid implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;

@end

NS_ASSUME_NONNULL_END
9 changes: 0 additions & 9 deletions objc/TINKMacConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import <Foundation/Foundation.h>

#import "TINKRegistryConfig.h"
#import "TINKVersion.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -49,14 +48,6 @@ NS_ASSUME_NONNULL_BEGIN
/* Returns config of Mac implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;

/**
* Returns config of Mac implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;

@end

NS_ASSUME_NONNULL_END
5 changes: 0 additions & 5 deletions objc/TINKRegistryConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

#import <Foundation/Foundation.h>

#import "TINKVersion.h"

NS_ASSUME_NONNULL_BEGIN

/**
Expand All @@ -39,9 +37,6 @@ NS_ASSUME_NONNULL_BEGIN

- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;

- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;

@end

NS_ASSUME_NONNULL_END
9 changes: 0 additions & 9 deletions objc/TINKSignatureConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import <Foundation/Foundation.h>

#import "TINKRegistryConfig.h"
#import "TINKVersion.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -47,14 +46,6 @@ NS_ASSUME_NONNULL_BEGIN
/* Use -initWithError: to get an instance of TINKSignatureConfig. */
- (nullable instancetype)init NS_UNAVAILABLE;

/**
* Returns config of Signature implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;

/* Returns config of Signature implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;

Expand Down
24 changes: 0 additions & 24 deletions objc/TINKVersion.h

This file was deleted.

1 change: 0 additions & 1 deletion objc/Tests/UnitTests/core/TINKAllConfigTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#import "objc/TINKConfig.h"
#import "objc/TINKRegistryConfig.h"
#import "objc/TINKVersion.h"
#import "objc/core/TINKRegistryConfig_Internal.h"
#import "objc/util/TINKStrings.h"

Expand Down
4 changes: 2 additions & 2 deletions objc/Tests/UnitTests/core/TINKKeysetHandleTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ - (void)testWriteKeysetToKeychain {

NSError *error = nil;
TINKAeadConfig *aeadConfig =
[[TINKAeadConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
[[TINKAeadConfig alloc] initWithError:&error];
XCTAssertNotNil(aeadConfig);
XCTAssertNil(error);

Expand Down Expand Up @@ -336,7 +336,7 @@ - (void)testDeleteKeysetFromKeychain {

NSError *error = nil;
TINKAeadConfig *aeadConfig =
[[TINKAeadConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
[[TINKAeadConfig alloc] initWithError:&error];
XCTAssertNotNil(aeadConfig);
XCTAssertNil(error);

Expand Down
10 changes: 0 additions & 10 deletions objc/Tests/UnitTests/signature/TINKSignatureConfigTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,4 @@ - (void)testConfigContents {
XCTAssertNil(error);
}

- (void)testConfigInvalidVersion {
NSError *error = nil;
TINKSignatureConfig *signatureConfig =
[[TINKSignatureConfig alloc] initWithVersion:(TINKVersion)-1 error:&error];
XCTAssertNil(signatureConfig);
XCTAssertNotNil(error);
XCTAssertTrue(error.code == crypto::tink::util::error::INVALID_ARGUMENT);
XCTAssertTrue([error.localizedFailureReason containsString:@"Unsupported Tink version."]);
}

@end
23 changes: 2 additions & 21 deletions objc/aead/TINKAeadConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import "objc/TINKAeadConfig.h"

#import "objc/TINKRegistryConfig.h"
#import "objc/TINKVersion.h"
#import "objc/core/TINKRegistryConfig_Internal.h"
#import "objc/util/TINKErrors.h"

Expand All @@ -31,7 +30,7 @@
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
@implementation TINKAeadConfig

- (instancetype)initWithVersion:(TINKVersion)version error:(NSError **)error {
- (nullable instancetype)initWithError:(NSError **)error {
auto st = crypto::tink::AeadConfig::Register();
if (!st.ok()) {
if (error) {
Expand All @@ -40,27 +39,9 @@ - (instancetype)initWithVersion:(TINKVersion)version error:(NSError **)error {
return nil;
}

google::crypto::tink::RegistryConfig ccConfig;
switch (version) {
case TINKVersion1_1_0:
// Fallthrough!
case TINKVersionLatest:
ccConfig = crypto::tink::AeadConfig::Latest();
break;
default:
if (error) {
*error = TINKStatusToError(crypto::tink::util::Status(
crypto::tink::util::error::INVALID_ARGUMENT, "Unsupported Tink version."));
}
return nil;
}

google::crypto::tink::RegistryConfig ccConfig = crypto::tink::AeadConfig::Latest();
return (self = [super initWithCcConfig:ccConfig]);
}

- (nullable instancetype)initWithError:(NSError **)error {
return [self initWithVersion:TINKVersionLatest error:error];
}

@end
#pragma clang diagnostic pop
22 changes: 2 additions & 20 deletions objc/core/TINKAllConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
#import <Foundation/Foundation.h>

#import "objc/TINKRegistryConfig.h"
#import "objc/TINKVersion.h"
#import "objc/core/TINKRegistryConfig_Internal.h"
#import "objc/util/TINKErrors.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
@implementation TINKAllConfig

- (instancetype)initWithVersion:(TINKVersion)version error:(NSError **)error {
- (nullable instancetype)initWithError:(NSError **)error {
auto st = crypto::tink::TinkConfig::Register();
if (!st.ok()) {
if (error) {
Expand All @@ -42,27 +41,10 @@ - (instancetype)initWithVersion:(TINKVersion)version error:(NSError **)error {
return nil;
}

google::crypto::tink::RegistryConfig ccConfig;
switch (version) {
case TINKVersion1_1_0:
// Fallthrough!
case TINKVersionLatest:
ccConfig = crypto::tink::TinkConfig::Latest();
break;
default:
if (error) {
*error = TINKStatusToError(crypto::tink::util::Status(
crypto::tink::util::error::INVALID_ARGUMENT, "Unsupported Tink version."));
}
return nil;
}
google::crypto::tink::RegistryConfig ccConfig = crypto::tink::TinkConfig::Latest();

return (self = [super initWithCcConfig:ccConfig]);
}

- (nullable instancetype)initWithError:(NSError **)error {
return [self initWithVersion:TINKVersionLatest error:error];
}

@end
#pragma clang diagnostic pop
6 changes: 0 additions & 6 deletions objc/core/TINKRegistryConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ - (void)setCcConfig:(google::crypto::tink::RegistryConfig)ccConfig {
return _ccConfig;
}

- (instancetype)initWithVersion:(TINKVersion)version error:(NSError **)error {
NSAssert(![self isMemberOfClass:[TINKRegistryConfig class]],
@"Only instantiate from derived classes!");
return nil;
}

- (nullable instancetype)initWithError:(NSError **)error {
NSAssert(![self isMemberOfClass:[TINKRegistryConfig class]],
@"Only instantiate from derived classes!");
Expand Down
Loading

0 comments on commit 627d621

Please sign in to comment.