PK.h 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. #include <AK/String.h>
  9. namespace Crypto {
  10. namespace PK {
  11. // FIXME: Fixing name up for grabs
  12. template<typename PrivKeyT, typename PubKeyT>
  13. class PKSystem {
  14. public:
  15. using PublicKeyType = PubKeyT;
  16. using PrivateKeyType = PrivKeyT;
  17. PKSystem(PublicKeyType& pubkey, PrivateKeyType& privkey)
  18. : m_public_key(pubkey)
  19. , m_private_key(privkey)
  20. {
  21. }
  22. PKSystem()
  23. {
  24. }
  25. virtual void encrypt(ReadonlyBytes in, Bytes& out) = 0;
  26. virtual void decrypt(ReadonlyBytes in, Bytes& out) = 0;
  27. virtual void sign(ReadonlyBytes in, Bytes& out) = 0;
  28. virtual void verify(ReadonlyBytes in, Bytes& out) = 0;
  29. virtual String class_name() const = 0;
  30. virtual size_t output_size() const = 0;
  31. protected:
  32. virtual ~PKSystem() = default;
  33. PublicKeyType m_public_key;
  34. PrivateKeyType m_private_key;
  35. };
  36. }
  37. }