Package ghidra.formats.gfilesystem.crypto

# Class CryptoProviders

java.lang.Object
ghidra.formats.gfilesystem.crypto.CryptoProviders

public class CryptoProviders extends Object
Registry of `crypto providers` and `session creator`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CachedPasswordProvider`
  `getCachedCryptoProvider()`
  Returns the `CachedPasswordProvider`.
  `<T extends CryptoProvider>
  T`
  `getCryptoProviderInstance(Class<T> providerClass)`
  Returns the previously registered matching `CryptoProvider` instance.
  `static CryptoProviders`
  `getInstance()`
  Fetch the global `CryptoProviders` singleton instance.
  `CryptoSession`
  `newSession()`
  Creates a new `CryptoSession`.
  `void`
  `registerCryptoProvider(CryptoProvider provider)`
  Adds a `CryptoProvider` to this registry.
  `void`
  `unregisterCryptoProvider(CryptoProvider provider)`
  Removes a `CryptoProvider` from this registry.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getInstance

    public static CryptoProviders getInstance()
    Fetch the global `CryptoProviders` singleton instance.
    Returns:
      shared `CryptoProviders` singleton instance

  - ### registerCryptoProvider

    public void registerCryptoProvider(CryptoProvider provider)
    Adds a `CryptoProvider` to this registry.

    TODO: do we need provider priority ordering?

    Parameters:
      `provider` - `CryptoProvider`

  - ### unregisterCryptoProvider

    public void unregisterCryptoProvider(CryptoProvider provider)
    Removes a `CryptoProvider` from this registry.
    Parameters:
      `provider` - `CryptoProvider` to remove

  - ### getCachedCryptoProvider

    public CachedPasswordProvider getCachedCryptoProvider()
    Returns the `CachedPasswordProvider`.

    (Used by GUI actions to manage the cache)

    Returns:
      cached crypto provider instance

  - ### getCryptoProviderInstance

    public <T extends CryptoProvider> T getCryptoProviderInstance(Class<T> providerClass)
    Returns the previously registered matching `CryptoProvider` instance.
    Type Parameters:
      `T` - CryptoProvider type
    Parameters:
      `providerClass` - `CryptoProvider` class
    Returns:
      previously registered CryptoProvider instance, or null if not found

  - ### newSession

    public CryptoSession newSession()
    Creates a new `CryptoSession`.

    TODO: to truly be effective when multiple files are being opened (ie. batch import), nested sessions need to be implemented.

    Returns:
      new `CryptoSession` instance