Community articleSecurityManager_LookupHashAlgorithm function
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.



Description

This function retrieves a hash object. Use the hash object to hash shared secrets for the UFLValidateHMACWithHashedSecret function.
Note that the hash object is tracked by reference counts, and must be released.

Function

   r_error SecurityManager_LookupHashAlgorithm(
      SecurityManager *theSecurityManager,
      r_charP algorithmName,
      Hash **theHash);


Parameters

Table 1. lookup hash algorithm parameters
ExpressionTypeDescription
theSecurityManager SecurityManager*The Security Manager object.
algorithmNamer_charPThe name of the hash algorithm you want to retrieve. The available hash algorithms are sha1 and md5.
theHashObject Hash**The hash algorithm object that the function retrieves. Note that this object is tracked by reference counts, and must be released.


Returns

OK on success or an error code on failure.

Example

The following example uses SecurityManager_GetSingleton to get the Security Manager object. The example then calls SecurityManager_LookupHashAlgorithm to get the sha1 hash algorithm. Finally, the SecurityManager object is released. (Note that the hash object is not released as it is passed back to the calling function.)
   r_error getHashAlgorithm(Hash **theHashObject);
   {
   SecurityManager *theSecurityManager;
   Hash *tempHashObject;
   r_error error;
 
   *theHashObject = NULL;
      if((error = SecurityManager_GetSingleton(&theSecurityManager)) 
         != OK)
      {
         fprintf(stderr, "SecurityManager_GetSingleton error %hd./n", 
            error);
         return(NOTOK);
      }
      if((error = SecurityManager_LookupHashAlgorithm(theSecurityManager, 
         "sha1", &tempHashObject)) != OK)
      {
         fprintf(stderr, "SecurityManager_LookupHashAlgorithm error %hd.
            /n"), error);
         return(NOTOK);
      }
 
      *theHashObject = tempHashObject;
 
      /* Relase the Security Manager object. */
 
      IFSObject_ReleaseRef((IFSObject*)theSecurityManager);
      return(OK);
   }