IAGGcmMathComponents.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // IAGGcmMathComponents.h
  3. // Pods
  4. //
  5. // Created by Enrique de la Torre (dev) on 20/09/2016.
  6. //
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "IAGTypes.h"
  10. /**
  11. Mathematical components used by the authenticated encryption and authenticated decryption functions.
  12. @see IAGAesGcm
  13. */
  14. NS_ASSUME_NONNULL_BEGIN
  15. @interface IAGGcmMathComponents : NSObject
  16. /**
  17. Quoting the documentation [here](http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf): "The authentication mechanism within GCM is based on a hash function, called GHASH, that features multiplication by a fixed parameter, called the hash subkey, within a binary Galois field.".
  18. @param ghashBlock Output parameter with the hash block
  19. @param buffer Input parameter with the data to hash
  20. @param bufferSize Length of the buffer, it has to be a multiple of sizeof(IAGBlockType)
  21. @param hashSubkey The hash subkey
  22. */
  23. + (void)getGhashBlock:(IAGBlockType _Nonnull )ghashBlock
  24. withBuffer:(IAGUCharType *)buffer
  25. bufferSize:(IAGSizeType)bufferSize
  26. hashSubkey:(IAGBlockType _Nonnull )hashSubkey;
  27. /**
  28. This method generates the counter buffers used during the encryption/decryption process.
  29. @param gcounterBuffer Output paramter with same size than inpit buffer
  30. @param buffer Input parameter
  31. @param bufferSize Size of the input buffer
  32. @param icb Initial Counter Block
  33. @param key Key used by the "Forward cipher function"
  34. @param error Set to a value if the operation fails
  35. @return YES if the operation is successful, NO in other case
  36. @see IAGAesGcm
  37. @see IAGErrorFactory
  38. @see [IAGAesComponents getCipheredBlock:byUsingAESOnBlock:withKey:error:]
  39. */
  40. + (BOOL)getGCounterBuffer:(IAGUCharType *)gcounterBuffer
  41. withBuffer:(IAGUCharType *)buffer
  42. bufferSize:(IAGSizeType)bufferSize
  43. initialCounterBlock:(IAGBlockType _Nonnull )icb
  44. key:(NSData *)key
  45. error:(NSError **)error;
  46. /**
  47. Increment the right-most 32 bits of the input buffer, regarded as an integer (modulo 2^32), and leave the remaining left-most bits unchanged.
  48. @param incBuffer Output parameter
  49. @param buffer Input paramater
  50. @param size Size of both buffers, it has to be greater than or equal to sizeof(IAGUInt32Type)
  51. */
  52. + (void)get32BitIncrementedBuffer:(IAGUCharType *)incBuffer
  53. withBuffer:(IAGUCharType *)buffer
  54. size:(IAGSizeType)size;
  55. @end
  56. NS_ASSUME_NONNULL_END