aboutsummaryrefslogtreecommitdiffstats
path: root/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt
blob: c64e9c9bf399b7dc2f9dc16f51761b9ea2ef2092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
 * SPDX-License-Identifier: GPL-3.0-only
 */

package dev.msfjarvis.aps.crypto

import java.io.InputStream
import java.io.OutputStream

/** Generic interface to implement cryptographic operations on top of. */
public interface CryptoHandler {

  /**
   * Decrypt the given [ciphertextStream] using a [privateKey] and [password], and writes the
   * resultant plaintext to [outputStream].
   */
  public fun decrypt(
    privateKey: String,
    password: String,
    ciphertextStream: InputStream,
    outputStream: OutputStream,
  )

  /**
   * Encrypt the given [plaintextStream] to the provided [pubKeys], and writes the encrypted
   * ciphertext to [outputStream].
   */
  public fun encrypt(
    pubKeys: List<String>,
    plaintextStream: InputStream,
    outputStream: OutputStream,
  )

  /** Given a [fileName], return whether this instance can handle it. */
  public fun canHandle(fileName: String): Boolean
}