Skip to content

Commit

Permalink
Javascript: remove catalogues.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 265110566
  • Loading branch information
thaidn authored and copybara-github committed Aug 23, 2019
1 parent 61c39da commit 3ba6100
Show file tree
Hide file tree
Showing 25 changed files with 15 additions and 2,034 deletions.
27 changes: 0 additions & 27 deletions javascript/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,12 @@ closure_js_library(
],
)

closure_js_library(
name = "catalogue",
srcs = [
"catalogue.js",
],
deps = [
":key_manager",
"@io_bazel_rules_closure//closure/library",
],
)

closure_js_library(
name = "registry",
srcs = [
"registry.js",
],
deps = [
":catalogue",
":key_manager",
":primitive_set",
":primitive_wrapper",
Expand Down Expand Up @@ -169,19 +157,4 @@ closure_js_library(
],
)

closure_js_library(
name = "config",
srcs = [
"config.js",
],
deps = [
":catalogue",
":key_manager",
":registry",
"//javascript/exception",
"//proto:config_closure_proto",
"@io_bazel_rules_closure//closure/library",
],
)

# test
20 changes: 0 additions & 20 deletions javascript/aead/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
closure_js_library(
name = "aead",
exports = [
":aead_catalogue",
":aead_config",
":aead_key_templates",
":aead_wrapper",
Expand Down Expand Up @@ -75,35 +74,16 @@ closure_js_library(
],
)

closure_js_library(
name = "aead_catalogue",
srcs = [
"aead_catalogue.js",
],
deps = [
":aes_ctr_hmac_aead_key_manager",
":aes_gcm_key_manager",
"//javascript:catalogue",
"//javascript:key_manager",
"//javascript:primitives",
"//javascript/exception",
"@io_bazel_rules_closure//closure/library",
],
)

closure_js_library(
name = "aead_config",
srcs = [
"aead_config.js",
],
deps = [
":aead_catalogue",
":aead_wrapper",
":aes_ctr_hmac_aead_key_manager",
":aes_gcm_key_manager",
"//javascript:config",
"//javascript:registry",
"//proto:config_closure_proto",
"@io_bazel_rules_closure//closure/library",
],
)
Expand Down
69 changes: 0 additions & 69 deletions javascript/aead/aead_catalogue.js

This file was deleted.

149 changes: 0 additions & 149 deletions javascript/aead/aead_catalogue_test.js

This file was deleted.

53 changes: 2 additions & 51 deletions javascript/aead/aead_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@

goog.module('tink.aead.AeadConfig');

const AeadCatalogue = goog.require('tink.aead.AeadCatalogue');
const AeadWrapper = goog.require('tink.aead.AeadWrapper');
const AesCtrHmacAeadKeyManager = goog.require('tink.aead.AesCtrHmacAeadKeyManager');
const AesGcmKeyManager = goog.require('tink.aead.AesGcmKeyManager');
const Config = goog.require('tink.Config');
const PbKeyTypeEntry = goog.require('proto.google.crypto.tink.KeyTypeEntry');
const PbRegistryConfig = goog.require('proto.google.crypto.tink.RegistryConfig');
const Registry = goog.require('tink.Registry');


Expand All @@ -37,69 +33,24 @@ const Registry = goog.require('tink.Registry');
* @final
*/
class AeadConfig {
/**
* Returns config of Aead implementations supported in the current Tink
* release.
*
* @return {!PbRegistryConfig}
*/
static latest() {
const config =
new PbRegistryConfig().setConfigName(AeadConfig.CONFIG_NAME_);

config.addEntry(AeadConfig.createEntry_(
AeadConfig.AES_CTR_HMAC_AEAD_TYPE_URL, /* keyManagerVersion = */ 0));

config.addEntry(AeadConfig.createEntry_(
AeadConfig.AES_GCM_TYPE_URL, /* keyManagerVersion = */ 0));

return config;
}

/**
* Registers key managers for all Aead key types from the current Tink
* release.
*/
static register() {
// TODO MacConfig.register() should be here.
Registry.addCatalogue(AeadConfig.CATALOGUE_NAME, new AeadCatalogue());
Registry.registerKeyManager(new AesGcmKeyManager());
Registry.registerKeyManager(new AesCtrHmacAeadKeyManager());
Registry.registerPrimitiveWrapper(new AeadWrapper());
Config.register(AeadConfig.latest());
}

/**
* Creates KeyTypeEntry for the given parameters. The primitiveName and
* catalogueName are set according to correspoding AeadConfig variables.
*
* @param {string} typeUrl
* @param {number} keyManagerVersion
* @param {boolean=} opt_newKeyAllowed
*
* @return {!PbKeyTypeEntry}
* @private
*/
static createEntry_(typeUrl, keyManagerVersion, opt_newKeyAllowed = true) {
const entry = new PbKeyTypeEntry()
.setPrimitiveName(AeadConfig.PRIMITIVE_NAME)
.setTypeUrl(typeUrl)
.setKeyManagerVersion(keyManagerVersion)
.setNewKeyAllowed(opt_newKeyAllowed)
.setCatalogueName(AeadConfig.CATALOGUE_NAME);

return entry;
}
}

/** @const @private {string} */
AeadConfig.CONFIG_NAME_ = 'TINK_AEAD';
/** @const {string} */
AeadConfig.CATALOGUE_NAME = 'TinkAead';
/** @const {string} */
AeadConfig.PRIMITIVE_NAME = 'Aead';

/** @const {string} */
AeadConfig.AES_CTR_HMAC_AEAD_TYPE_URL = AesCtrHmacAeadKeyManager.KEY_TYPE;

/** @const {string} */
AeadConfig.AES_GCM_TYPE_URL = AesGcmKeyManager.KEY_TYPE;

Expand Down
Loading

0 comments on commit 3ba6100

Please sign in to comment.