PPOTEncryptionHelper.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // PPOTEncryptionHelper.h
  3. // PayPalOneTouch
  4. //
  5. // Copyright © 2015 PayPal, Inc. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. /**
  9. Used handle encryption related to PayPal payments
  10. */
  11. @interface PPOTEncryptionHelper : NSObject
  12. /**
  13. Generates a random 256-bit key to encrypt data with
  14. @return a 256-bit encryption key
  15. */
  16. + (nonnull NSData *)generate256BitKey;
  17. /**
  18. Encrypt the data using the encryption key.
  19. @param plainData the data to encrypt
  20. @param key the encryption key to use
  21. @return the encrypted data
  22. */
  23. + (nullable NSData *)encryptAESCTRData:(nonnull NSData *)plainData encryptionKey:(nonnull NSData *)key;
  24. /**
  25. Decrypt the data using the encryption key.
  26. @param cipherData the encrypted data
  27. @param key the encryption key used
  28. @return the decrypted data
  29. */
  30. + (nullable NSData *)decryptAESCTRData:(nonnull NSData *)cipherData encryptionKey:(nonnull NSData *)key;
  31. /**
  32. Encrypts data using the given certificate
  33. @param plainData the data to encrypt
  34. @param certificate the certificate to use
  35. @return the encrypted data
  36. */
  37. + (nullable NSData *)encryptRSAData:(nonnull NSData *)plainData certificate:(nonnull NSData *)certificate;
  38. @end