@Override public final void onCreate() { super.onCreate(); try { Config.register(TinkConfig.TINK_1_0_0); aead = getOrGenerateNewKeysetHandle().getPrimitive(Aead.class); } catch (GeneralSecurityException | IOException e) { throw new RuntimeException(e); } }
/** * Tries to register key managers according to the specification in {@code config}. * * @throws GeneralSecurityException if cannot register this config with the {@link Registry}. This * usually happens when either {@code config} contains any {@link KeyTypeEntry} that is * already registered or the Registry cannot find any {@link * com.google.crypto.tink.KeyManager} or {@link com.google.crypto.tink.Catalogue} that can * handle the entry. In both cases the error message should show how to resolve it. */ public static void register(RegistryConfig config) throws GeneralSecurityException { for (KeyTypeEntry entry : config.getEntryList()) { registerKeyType(entry); } }
/** * Tries to register a key manager according to the specification in {@code entry}. * * @throws GeneralSecurityException if cannot register this config with the {@link Registry}. This * usually happens when {@code entry} is already registered or the Registry cannot find any * {@link com.google.crypto.tink.KeyManager} or {@link com.google.crypto.tink.Catalogue} that * can handle the entry. In both cases the error message should show how to resolve it. */ @SuppressWarnings({"rawtypes", "unchecked"}) public static void registerKeyType(KeyTypeEntry entry) throws GeneralSecurityException { validate(entry); Catalogue catalogue = Registry.getCatalogue(entry.getCatalogueName()); KeyManager keyManager = catalogue.getKeyManager( entry.getTypeUrl(), entry.getPrimitiveName(), entry.getKeyManagerVersion()); Registry.registerKeyManager(keyManager, entry.getNewKeyAllowed()); }
/** * Initializes the Capillary library. * * <p>This should be called before using any functionality provided by Capillary. * * @throws GeneralSecurityException if the initialization fails. */ public static void initialize() throws GeneralSecurityException { com.google.crypto.tink.Config.register(SignatureConfig.TINK_1_1_0); com.google.crypto.tink.Config.register(AeadConfig.TINK_1_1_0); } }
/** * Initializes the Capillary library. * * <p>This should be called before using any functionality provided by Capillary. * * @throws GeneralSecurityException if the initialization fails. */ public static void initialize() throws GeneralSecurityException { com.google.crypto.tink.Config.register(SignatureConfig.TINK_1_1_0); com.google.crypto.tink.Config.register(AeadConfig.TINK_1_1_0); } }
/** * Registers standard with the {@code Registry} all HybridDecrypt key types released with the * latest version of Tink. * * <p>Deprecated-yet-still-supported key types are registered in so-called "no new key"-mode, * which allows for usage of existing keys forbids generation of new key material. * * @deprecated use {@link Config#register} */ @Deprecated public static void registerStandardKeyTypes() throws GeneralSecurityException { Config.register(HybridConfig.TINK_1_0_0); } }
/** * Registers standard with the {@code Registry} all PublicKeyVerify key types released with the * latest version of Tink. * * <p>Deprecated-yet-still-supported key types are registered in so-called "no new key"-mode, * which allows for usage of existing keys forbids generation of new key material. * * @deprecated use {@link Config#register} */ @Deprecated public static void registerStandardKeyTypes() throws GeneralSecurityException { Config.register(SignatureConfig.TINK_1_0_0); } }
/** * Registers standard with the {@code Registry} all PublicKeySign key types released with the * latest version of Tink. * * <p>Deprecated-yet-still-supported key types are registered in so-called "no new key"-mode, * which allows for usage of existing keys forbids generation of new key material. * * @deprecated use {@link Config#register} */ @Deprecated public static void registerStandardKeyTypes() throws GeneralSecurityException { Config.register(SignatureConfig.TINK_1_0_0); } }
/** * Registers standard with the {@code Registry} all HybridEncrypt key types released with the * latest version of Tink. * * <p>Deprecated-yet-still-supported key types are registered in so-called "no new key"-mode, * which allows for usage of existing keys forbids generation of new key material. * * @deprecated use {@link Config#register} */ @Deprecated public static void registerStandardKeyTypes() throws GeneralSecurityException { Config.register(HybridConfig.TINK_1_0_0); } }
/** * Parses the command line arguments and generates an ECDSA private/private key pair. */ public static void main(String[] args) throws Exception { Config.register(SignatureConfig.TINK_1_1_0); CommandLine commandLine = generateCommandLine(args); generateEcdsaKeyPair( new File(commandLine.getOptionValue(ECDSA_PUBLIC_KEY_PATH_OPTION)), new File(commandLine.getOptionValue(ECDSA_PRIVATE_KEY_PATH_OPTION))); }
/** * Tries to register with the {@link Registry} all instances of {@link * com.google.crypto.tink.Catalogue} needed to handle StreamingAead key types supported in Tink. * * @since 1.2.0 */ public static void register() throws GeneralSecurityException { Registry.addCatalogue(CATALOGUE_NAME, new StreamingAeadCatalogue()); Config.register(LATEST); } }
/** * Tries to register with the {@link Registry} all instances of {@link * com.google.crypto.tink.Catalogue} and {@link com.google.crypto.tink.KeyManager} needed to * handle Mac key types supported in Tink. * * @since 1.2.0 */ public static void register() throws GeneralSecurityException { Registry.addCatalogue(CATALOGUE_NAME, new MacCatalogue()); Config.register(LATEST); }
/** * Tries to register with the {@link Registry} all instances of {@link * com.google.crypto.tink.Catalogue} needed to handle DeterministicAead key types supported in * Tink. * * @since 1.2.0 */ public static void register() throws GeneralSecurityException { Registry.addCatalogue(CATALOGUE_NAME, new DeterministicAeadCatalogue()); Config.register(LATEST); } }
/** * Tries to register with the {@link Registry} all instances of {@link * com.google.crypto.tink.Catalogue} and {@link com.google.crypto.tink.KeyManager} needed to * handle Aead key types supported in Tink. * * <p>Because Aead key types depend on {@link com.google.crypto.tink.Mac} key types, this method * also registers all Mac catalogues and key managers. * * @since 1.2.0 */ public static void register() throws GeneralSecurityException { // The order of these calls matters. MacConfig.register(); Registry.addCatalogue(CATALOGUE_NAME, new AeadCatalogue()); Config.register(LATEST); }
/** * Tries to register with the {@link Registry} all instances of {@link * com.google.crypto.tink.Catalogue} needed to handle PublicKeySign and PublicKeyVerify key types * supported in Tink. * * @since 1.2.0 */ public static void register() throws GeneralSecurityException { Registry.addCatalogue(PUBLIC_KEY_SIGN_CATALOGUE_NAME, new PublicKeySignCatalogue()); Registry.addCatalogue(PUBLIC_KEY_VERIFY_CATALOGUE_NAME, new PublicKeyVerifyCatalogue()); Config.register(LATEST); } }
/** * Tries to register with the {@link Registry} all instances of {@link * com.google.crypto.tink.Catalogue} needed to handle HybridDecrypt and HybridEncrypt key types * supported in Tink. * * <p>Because HybridDecrypt and HybridEncrypt key types depend on {@link * com.google.crypto.tink.Aead} and {@link com.google.crypto.tink.Mac} key types, this method also * registers all Aead and Mac catalogues. * * @since 1.2.0 */ public static void register() throws GeneralSecurityException { // The order of these calls matters. AeadConfig.register(); // includes Mac Registry.addCatalogue(HYBRID_ENCRYPT_CATALOGUE_NAME, new HybridEncryptCatalogue()); Registry.addCatalogue(HYBRID_DECRYPT_CATALOGUE_NAME, new HybridDecryptCatalogue()); Config.register(LATEST); } }