size_t findPubKey()

in macos/midtier.c [141:162]


size_t findPubKey(
    const char* label,
    const char* tag,
    unsigned char* hash,
    unsigned char** ret,
    char** error) {
  CFDataRef pubKey = NULL;
  OSStatus status = FetchSEKey(label, tag, hash, &pubKey);
  if (status != errSecSuccess && status != errSecItemNotFound) {
    CFStringRef errStr = SecCopyErrorMessageString(status, NULL);
    *error = CFStringToCString(errStr);
    CFRelease((CFTypeRef)errStr);
    return 0;
  }
  if (!pubKey)
    return 0;

  *ret = CFDataToUint8(pubKey);
  CFIndex size = CFDataGetLength(pubKey);
  CFRelease((CFTypeRef)pubKey);
  return (size_t)size;
}