digisign.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef DIGISIGN_HPP
  14. #define DIGISIGN_HPP
  15. #ifndef DIGISIGN_API
  16. #ifndef DIGISIGN_EXPORTS
  17. #define DIGISIGN_API DECL_IMPORT
  18. #else
  19. #define DIGISIGN_API DECL_EXPORT
  20. #endif //DIGISIGN_EXPORTS
  21. #endif
  22. //General purpose digital signature manager
  23. //Useful to sign a text string, so the consumer can be assured it has not been altered
  24. interface IDigitalSignatureManager : extends IInterface //Public/Private key message signer/verifyer
  25. {
  26. public:
  27. virtual bool isDigiSignerConfigured() = 0;
  28. virtual bool isDigiVerifierConfigured() = 0;
  29. virtual bool digiSign(const char * text, StringBuffer & b64Signature) = 0;//signs, using private key
  30. virtual bool digiVerify(const char * text, StringBuffer & b64Signature) = 0;//verifies, using public key
  31. };
  32. extern "C"
  33. {
  34. //Uses the HPCCPublicKey/HPCCPrivateKey key files specified in environment.conf
  35. DIGISIGN_API IDigitalSignatureManager * createDigitalSignatureManagerInstanceFromEnv();
  36. //Create using the given key files
  37. DIGISIGN_API IDigitalSignatureManager * createDigitalSignatureManagerInstanceFromFiles(const char * _pubKey, const char *_privKey, const char * _passPhrase);
  38. //Create using the given PEM formatted keys
  39. DIGISIGN_API IDigitalSignatureManager * createDigitalSignatureManagerInstanceFromKeys(StringBuffer & _pubKeyBuff, StringBuffer & _privKeyBuff, const char * _passPhrase);
  40. }
  41. #endif