Skip to content

Instantly share code, notes, and snippets.

@KoCMoHaBTa
Last active February 9, 2023 11:57
Show Gist options
  • Save KoCMoHaBTa/d90dd89c5af4f194848486e78fd39f96 to your computer and use it in GitHub Desktop.
Save KoCMoHaBTa/d90dd89c5af4f194848486e78fd39f96 to your computer and use it in GitHub Desktop.
OSStatus Utilities
//https://gist.github.com/KoCMoHaBTa/d90dd89c5af4f194848486e78fd39f96
import Foundation
let OSStatusErrorCodeMessageMapping: [OSStatus: String] = [
//the following lines are autogenerated trough OSStatusErrorCodeMessageMappingParser from swift's SecBase (CMD + click on any OSStatus code)
errSecSuccess: "errSecSuccess - No error.",
errSecUnimplemented: "errSecUnimplemented - Function or operation not implemented.",
// errSecDskFull: "errSecDskFull", //conflicts with errSecDiskFull
errSecIO: "errSecIO - I/O error (bummers)",
errSecOpWr: "errSecOpWr - file already open with with write permission",
errSecParam: "errSecParam - One or more parameters passed to a function were not valid.",
errSecWrPerm: "errSecWrPerm - write permissions error",
errSecAllocate: "errSecAllocate - Failed to allocate memory.",
errSecUserCanceled: "errSecUserCanceled - User canceled the operation.",
errSecBadReq: "errSecBadReq - Bad parameter or invalid state for operation.",
errSecInternalComponent: "errSecInternalComponent",
errSecCoreFoundationUnknown: "errSecCoreFoundationUnknown",
errSecNotAvailable: "errSecNotAvailable - No keychain is available. You may need to restart your computer.",
errSecReadOnly: "errSecReadOnly - This keychain cannot be modified.",
errSecAuthFailed: "errSecAuthFailed - The user name or passphrase you entered is not correct.",
errSecNoSuchKeychain: "errSecNoSuchKeychain - The specified keychain could not be found.",
errSecInvalidKeychain: "errSecInvalidKeychain - The specified keychain is not a valid keychain file.",
errSecDuplicateKeychain: "errSecDuplicateKeychain - A keychain with the same name already exists.",
errSecDuplicateCallback: "errSecDuplicateCallback - The specified callback function is already installed.",
errSecInvalidCallback: "errSecInvalidCallback - The specified callback function is not valid.",
errSecDuplicateItem: "errSecDuplicateItem - The specified item already exists in the keychain.",
errSecItemNotFound: "errSecItemNotFound - The specified item could not be found in the keychain.",
errSecBufferTooSmall: "errSecBufferTooSmall - There is not enough memory available to use the specified item.",
errSecDataTooLarge: "errSecDataTooLarge - This item contains information which is too large or in a format that cannot be displayed.",
errSecNoSuchAttr: "errSecNoSuchAttr - The specified attribute does not exist.",
errSecInvalidItemRef: "errSecInvalidItemRef - The specified item is no longer valid. It may have been deleted from the keychain.",
errSecInvalidSearchRef: "errSecInvalidSearchRef - Unable to search the current keychain.",
errSecNoSuchClass: "errSecNoSuchClass - The specified item does not appear to be a valid keychain item.",
errSecNoDefaultKeychain: "errSecNoDefaultKeychain - A default keychain could not be found.",
errSecInteractionNotAllowed: "errSecInteractionNotAllowed - User interaction is not allowed.",
errSecReadOnlyAttr: "errSecReadOnlyAttr - The specified attribute could not be modified.",
errSecWrongSecVersion: "errSecWrongSecVersion - This keychain was created by a different version of the system software and cannot be opened.",
errSecKeySizeNotAllowed: "errSecKeySizeNotAllowed - This item specifies a key size which is too large.",
errSecNoStorageModule: "errSecNoStorageModule - A required component (data storage module) could not be loaded. You may need to restart your computer.",
errSecNoCertificateModule: "errSecNoCertificateModule - A required component (certificate module) could not be loaded. You may need to restart your computer.",
errSecNoPolicyModule: "errSecNoPolicyModule - A required component (policy module) could not be loaded. You may need to restart your computer.",
errSecInteractionRequired: "errSecInteractionRequired - User interaction is required, but is currently not allowed.",
errSecDataNotAvailable: "errSecDataNotAvailable - The contents of this item cannot be retrieved.",
errSecDataNotModifiable: "errSecDataNotModifiable - The contents of this item cannot be modified.",
errSecCreateChainFailed: "errSecCreateChainFailed - One or more certificates required to validate this certificate cannot be found.",
errSecInvalidPrefsDomain: "errSecInvalidPrefsDomain - The specified preferences domain is not valid.",
errSecInDarkWake: "errSecInDarkWake - In dark wake, no UI possible",
errSecACLNotSimple: "errSecACLNotSimple - The specified access control list is not in standard (simple) form.",
errSecPolicyNotFound: "errSecPolicyNotFound - The specified policy cannot be found.",
errSecInvalidTrustSetting: "errSecInvalidTrustSetting - The specified trust setting is invalid.",
errSecNoAccessForItem: "errSecNoAccessForItem - The specified item has no access control.",
errSecInvalidOwnerEdit: "errSecInvalidOwnerEdit - Invalid attempt to change the owner of this item.",
errSecTrustNotAvailable: "errSecTrustNotAvailable - No trust results are available.",
errSecUnsupportedFormat: "errSecUnsupportedFormat - Import/Export format unsupported.",
errSecUnknownFormat: "errSecUnknownFormat - Unknown format in import.",
errSecKeyIsSensitive: "errSecKeyIsSensitive - Key material must be wrapped for export.",
errSecMultiplePrivKeys: "errSecMultiplePrivKeys - An attempt was made to import multiple private keys.",
errSecPassphraseRequired: "errSecPassphraseRequired - Passphrase is required for import/export.",
errSecInvalidPasswordRef: "errSecInvalidPasswordRef - The password reference was invalid.",
errSecInvalidTrustSettings: "errSecInvalidTrustSettings - The Trust Settings Record was corrupted.",
errSecNoTrustSettings: "errSecNoTrustSettings - No Trust Settings were found.",
errSecPkcs12VerifyFailure: "errSecPkcs12VerifyFailure - MAC verification failed during PKCS12 import (wrong password?)",
errSecNotSigner: "errSecNotSigner - A certificate was not signed by its proposed parent.",
errSecDecode: "errSecDecode - Unable to decode the provided data.",
errSecServiceNotAvailable: "errSecServiceNotAvailable - The required service is not available.",
errSecInsufficientClientID: "errSecInsufficientClientID - The client ID is not correct.",
errSecDeviceReset: "errSecDeviceReset - A device reset has occurred.",
errSecDeviceFailed: "errSecDeviceFailed - A device failure has occurred.",
errSecAppleAddAppACLSubject: "errSecAppleAddAppACLSubject - Adding an application ACL subject failed.",
errSecApplePublicKeyIncomplete: "errSecApplePublicKeyIncomplete - The public key is incomplete.",
errSecAppleSignatureMismatch: "errSecAppleSignatureMismatch - A signature mismatch has occurred.",
errSecAppleInvalidKeyStartDate: "errSecAppleInvalidKeyStartDate - The specified key has an invalid start date.",
errSecAppleInvalidKeyEndDate: "errSecAppleInvalidKeyEndDate - The specified key has an invalid end date.",
errSecConversionError: "errSecConversionError - A conversion error has occurred.",
errSecAppleSSLv2Rollback: "errSecAppleSSLv2Rollback - A SSLv2 rollback error has occurred.",
errSecDiskFull: "errSecDiskFull - The disk is full.",
errSecQuotaExceeded: "errSecQuotaExceeded - The quota was exceeded.",
errSecFileTooBig: "errSecFileTooBig - The file is too big.",
errSecInvalidDatabaseBlob: "errSecInvalidDatabaseBlob - The specified database has an invalid blob.",
errSecInvalidKeyBlob: "errSecInvalidKeyBlob - The specified database has an invalid key blob.",
errSecIncompatibleDatabaseBlob: "errSecIncompatibleDatabaseBlob - The specified database has an incompatible blob.",
errSecIncompatibleKeyBlob: "errSecIncompatibleKeyBlob - The specified database has an incompatible key blob.",
errSecHostNameMismatch: "errSecHostNameMismatch - A host name mismatch has occurred.",
errSecUnknownCriticalExtensionFlag: "errSecUnknownCriticalExtensionFlag - There is an unknown critical extension flag.",
errSecNoBasicConstraints: "errSecNoBasicConstraints - No basic constraints were found.",
errSecNoBasicConstraintsCA: "errSecNoBasicConstraintsCA - No basic CA constraints were found.",
errSecInvalidAuthorityKeyID: "errSecInvalidAuthorityKeyID - The authority key ID is not valid.",
errSecInvalidSubjectKeyID: "errSecInvalidSubjectKeyID - The subject key ID is not valid.",
errSecInvalidKeyUsageForPolicy: "errSecInvalidKeyUsageForPolicy - The key usage is not valid for the specified policy.",
errSecInvalidExtendedKeyUsage: "errSecInvalidExtendedKeyUsage - The extended key usage is not valid.",
errSecInvalidIDLinkage: "errSecInvalidIDLinkage - The ID linkage is not valid.",
errSecPathLengthConstraintExceeded: "errSecPathLengthConstraintExceeded - The path length constraint was exceeded.",
errSecInvalidRoot: "errSecInvalidRoot - The root or anchor certificate is not valid.",
errSecCRLExpired: "errSecCRLExpired - The CRL has expired.",
errSecCRLNotValidYet: "errSecCRLNotValidYet - The CRL is not yet valid.",
errSecCRLNotFound: "errSecCRLNotFound - The CRL was not found.",
errSecCRLServerDown: "errSecCRLServerDown - The CRL server is down.",
errSecCRLBadURI: "errSecCRLBadURI - The CRL has a bad Uniform Resource Identifier.",
errSecUnknownCertExtension: "errSecUnknownCertExtension - An unknown certificate extension was encountered.",
errSecUnknownCRLExtension: "errSecUnknownCRLExtension - An unknown CRL extension was encountered.",
errSecCRLNotTrusted: "errSecCRLNotTrusted - The CRL is not trusted.",
errSecCRLPolicyFailed: "errSecCRLPolicyFailed - The CRL policy failed.",
errSecIDPFailure: "errSecIDPFailure - The issuing distribution point was not valid.",
errSecSMIMEEmailAddressesNotFound: "errSecSMIMEEmailAddressesNotFound - An email address mismatch was encountered.",
errSecSMIMEBadExtendedKeyUsage: "errSecSMIMEBadExtendedKeyUsage - The appropriate extended key usage for SMIME was not found.",
errSecSMIMEBadKeyUsage: "errSecSMIMEBadKeyUsage - The key usage is not compatible with SMIME.",
errSecSMIMEKeyUsageNotCritical: "errSecSMIMEKeyUsageNotCritical - The key usage extension is not marked as critical.",
errSecSMIMENoEmailAddress: "errSecSMIMENoEmailAddress - No email address was found in the certificate.",
errSecSMIMESubjAltNameNotCritical: "errSecSMIMESubjAltNameNotCritical - The subject alternative name extension is not marked as critical.",
errSecSSLBadExtendedKeyUsage: "errSecSSLBadExtendedKeyUsage - The appropriate extended key usage for SSL was not found.",
errSecOCSPBadResponse: "errSecOCSPBadResponse - The OCSP response was incorrect or could not be parsed.",
errSecOCSPBadRequest: "errSecOCSPBadRequest - The OCSP request was incorrect or could not be parsed.",
errSecOCSPUnavailable: "errSecOCSPUnavailable - OCSP service is unavailable.",
errSecOCSPStatusUnrecognized: "errSecOCSPStatusUnrecognized - The OCSP server did not recognize this certificate.",
errSecEndOfData: "errSecEndOfData - An end-of-data was detected.",
errSecIncompleteCertRevocationCheck: "errSecIncompleteCertRevocationCheck - An incomplete certificate revocation check occurred.",
errSecNetworkFailure: "errSecNetworkFailure - A network failure occurred.",
errSecOCSPNotTrustedToAnchor: "errSecOCSPNotTrustedToAnchor - The OCSP response was not trusted to a root or anchor certificate.",
errSecRecordModified: "errSecRecordModified - The record was modified.",
errSecOCSPSignatureError: "errSecOCSPSignatureError - The OCSP response had an invalid signature.",
errSecOCSPNoSigner: "errSecOCSPNoSigner - The OCSP response had no signer.",
errSecOCSPResponderMalformedReq: "errSecOCSPResponderMalformedReq - The OCSP responder was given a malformed request.",
errSecOCSPResponderInternalError: "errSecOCSPResponderInternalError - The OCSP responder encountered an internal error.",
errSecOCSPResponderTryLater: "errSecOCSPResponderTryLater - The OCSP responder is busy, try again later.",
errSecOCSPResponderSignatureRequired: "errSecOCSPResponderSignatureRequired - The OCSP responder requires a signature.",
errSecOCSPResponderUnauthorized: "errSecOCSPResponderUnauthorized - The OCSP responder rejected this request as unauthorized.",
errSecOCSPResponseNonceMismatch: "errSecOCSPResponseNonceMismatch - The OCSP response nonce did not match the request.",
errSecCodeSigningBadCertChainLength: "errSecCodeSigningBadCertChainLength - Code signing encountered an incorrect certificate chain length.",
errSecCodeSigningNoBasicConstraints: "errSecCodeSigningNoBasicConstraints - Code signing found no basic constraints.",
errSecCodeSigningBadPathLengthConstraint: "errSecCodeSigningBadPathLengthConstraint - Code signing encountered an incorrect path length constraint.",
errSecCodeSigningNoExtendedKeyUsage: "errSecCodeSigningNoExtendedKeyUsage - Code signing found no extended key usage.",
errSecCodeSigningDevelopment: "errSecCodeSigningDevelopment - Code signing indicated use of a development-only certificate.",
errSecResourceSignBadCertChainLength: "errSecResourceSignBadCertChainLength - Resource signing has encountered an incorrect certificate chain length.",
errSecResourceSignBadExtKeyUsage: "errSecResourceSignBadExtKeyUsage - Resource signing has encountered an error in the extended key usage.",
errSecTrustSettingDeny: "errSecTrustSettingDeny - The trust setting for this policy was set to Deny.",
errSecInvalidSubjectName: "errSecInvalidSubjectName - An invalid certificate subject name was encountered.",
errSecUnknownQualifiedCertStatement: "errSecUnknownQualifiedCertStatement - An unknown qualified certificate statement was encountered.",
errSecMobileMeRequestQueued: "errSecMobileMeRequestQueued - The MobileMe request will be sent during the next connection.",
errSecMobileMeRequestRedirected: "errSecMobileMeRequestRedirected - The MobileMe request was redirected.",
errSecMobileMeServerError: "errSecMobileMeServerError - A MobileMe server error occurred.",
errSecMobileMeServerNotAvailable: "errSecMobileMeServerNotAvailable - The MobileMe server is not available.",
errSecMobileMeServerAlreadyExists: "errSecMobileMeServerAlreadyExists - The MobileMe server reported that the item already exists.",
errSecMobileMeServerServiceErr: "errSecMobileMeServerServiceErr - A MobileMe service error has occurred.",
errSecMobileMeRequestAlreadyPending: "errSecMobileMeRequestAlreadyPending - A MobileMe request is already pending.",
errSecMobileMeNoRequestPending: "errSecMobileMeNoRequestPending - MobileMe has no request pending.",
errSecMobileMeCSRVerifyFailure: "errSecMobileMeCSRVerifyFailure - A MobileMe CSR verification failure has occurred.",
errSecMobileMeFailedConsistencyCheck: "errSecMobileMeFailedConsistencyCheck - MobileMe has found a failed consistency check.",
errSecNotInitialized: "errSecNotInitialized - A function was called without initializing CSSM.",
errSecInvalidHandleUsage: "errSecInvalidHandleUsage - The CSSM handle does not match with the service type.",
errSecPVCReferentNotFound: "errSecPVCReferentNotFound - A reference to the calling module was not found in the list of authorized callers.",
errSecFunctionIntegrityFail: "errSecFunctionIntegrityFail - A function address was not within the verified module.",
errSecInternalError: "errSecInternalError - An internal error has occurred.",
errSecMemoryError: "errSecMemoryError - A memory error has occurred.",
errSecInvalidData: "errSecInvalidData - Invalid data was encountered.",
errSecMDSError: "errSecMDSError - A Module Directory Service error has occurred.",
errSecInvalidPointer: "errSecInvalidPointer - An invalid pointer was encountered.",
errSecSelfCheckFailed: "errSecSelfCheckFailed - Self-check has failed.",
errSecFunctionFailed: "errSecFunctionFailed - A function has failed.",
errSecModuleManifestVerifyFailed: "errSecModuleManifestVerifyFailed - A module manifest verification failure has occurred.",
errSecInvalidGUID: "errSecInvalidGUID - An invalid GUID was encountered.",
errSecInvalidHandle: "errSecInvalidHandle - An invalid handle was encountered.",
errSecInvalidDBList: "errSecInvalidDBList - An invalid DB list was encountered.",
errSecInvalidPassthroughID: "errSecInvalidPassthroughID - An invalid passthrough ID was encountered.",
errSecInvalidNetworkAddress: "errSecInvalidNetworkAddress - An invalid network address was encountered.",
errSecCRLAlreadySigned: "errSecCRLAlreadySigned - The certificate revocation list is already signed.",
errSecInvalidNumberOfFields: "errSecInvalidNumberOfFields - An invalid number of fields were encountered.",
errSecVerificationFailure: "errSecVerificationFailure - A verification failure occurred.",
errSecUnknownTag: "errSecUnknownTag - An unknown tag was encountered.",
errSecInvalidSignature: "errSecInvalidSignature - An invalid signature was encountered.",
errSecInvalidName: "errSecInvalidName - An invalid name was encountered.",
errSecInvalidCertificateRef: "errSecInvalidCertificateRef - An invalid certificate reference was encountered.",
errSecInvalidCertificateGroup: "errSecInvalidCertificateGroup - An invalid certificate group was encountered.",
errSecTagNotFound: "errSecTagNotFound - The specified tag was not found.",
errSecInvalidQuery: "errSecInvalidQuery - The specified query was not valid.",
errSecInvalidValue: "errSecInvalidValue - An invalid value was detected.",
errSecCallbackFailed: "errSecCallbackFailed - A callback has failed.",
errSecACLDeleteFailed: "errSecACLDeleteFailed - An ACL delete operation has failed.",
errSecACLReplaceFailed: "errSecACLReplaceFailed - An ACL replace operation has failed.",
errSecACLAddFailed: "errSecACLAddFailed - An ACL add operation has failed.",
errSecACLChangeFailed: "errSecACLChangeFailed - An ACL change operation has failed.",
errSecInvalidAccessCredentials: "errSecInvalidAccessCredentials - Invalid access credentials were encountered.",
errSecInvalidRecord: "errSecInvalidRecord - An invalid record was encountered.",
errSecInvalidACL: "errSecInvalidACL - An invalid ACL was encountered.",
errSecInvalidSampleValue: "errSecInvalidSampleValue - An invalid sample value was encountered.",
errSecIncompatibleVersion: "errSecIncompatibleVersion - An incompatible version was encountered.",
errSecPrivilegeNotGranted: "errSecPrivilegeNotGranted - The privilege was not granted.",
errSecInvalidScope: "errSecInvalidScope - An invalid scope was encountered.",
errSecPVCAlreadyConfigured: "errSecPVCAlreadyConfigured - The PVC is already configured.",
errSecInvalidPVC: "errSecInvalidPVC - An invalid PVC was encountered.",
errSecEMMLoadFailed: "errSecEMMLoadFailed - The EMM load has failed.",
errSecEMMUnloadFailed: "errSecEMMUnloadFailed - The EMM unload has failed.",
errSecAddinLoadFailed: "errSecAddinLoadFailed - The add-in load operation has failed.",
errSecInvalidKeyRef: "errSecInvalidKeyRef - An invalid key was encountered.",
errSecInvalidKeyHierarchy: "errSecInvalidKeyHierarchy - An invalid key hierarchy was encountered.",
errSecAddinUnloadFailed: "errSecAddinUnloadFailed - The add-in unload operation has failed.",
errSecLibraryReferenceNotFound: "errSecLibraryReferenceNotFound - A library reference was not found.",
errSecInvalidAddinFunctionTable: "errSecInvalidAddinFunctionTable - An invalid add-in function table was encountered.",
errSecInvalidServiceMask: "errSecInvalidServiceMask - An invalid service mask was encountered.",
errSecModuleNotLoaded: "errSecModuleNotLoaded - A module was not loaded.",
errSecInvalidSubServiceID: "errSecInvalidSubServiceID - An invalid subservice ID was encountered.",
errSecAttributeNotInContext: "errSecAttributeNotInContext - An attribute was not in the context.",
errSecModuleManagerInitializeFailed: "errSecModuleManagerInitializeFailed - A module failed to initialize.",
errSecModuleManagerNotFound: "errSecModuleManagerNotFound - A module was not found.",
errSecEventNotificationCallbackNotFound: "errSecEventNotificationCallbackNotFound - An event notification callback was not found.",
errSecInputLengthError: "errSecInputLengthError - An input length error was encountered.",
errSecOutputLengthError: "errSecOutputLengthError - An output length error was encountered.",
errSecPrivilegeNotSupported: "errSecPrivilegeNotSupported - The privilege is not supported.",
errSecDeviceError: "errSecDeviceError - A device error was encountered.",
errSecAttachHandleBusy: "errSecAttachHandleBusy - The CSP handle was busy.",
errSecNotLoggedIn: "errSecNotLoggedIn - You are not logged in.",
errSecAlgorithmMismatch: "errSecAlgorithmMismatch - An algorithm mismatch was encountered.",
errSecKeyUsageIncorrect: "errSecKeyUsageIncorrect - The key usage is incorrect.",
errSecKeyBlobTypeIncorrect: "errSecKeyBlobTypeIncorrect - The key blob type is incorrect.",
errSecKeyHeaderInconsistent: "errSecKeyHeaderInconsistent - The key header is inconsistent.",
errSecUnsupportedKeyFormat: "errSecUnsupportedKeyFormat - The key header format is not supported.",
errSecUnsupportedKeySize: "errSecUnsupportedKeySize - The key size is not supported.",
errSecInvalidKeyUsageMask: "errSecInvalidKeyUsageMask - The key usage mask is not valid.",
errSecUnsupportedKeyUsageMask: "errSecUnsupportedKeyUsageMask - The key usage mask is not supported.",
errSecInvalidKeyAttributeMask: "errSecInvalidKeyAttributeMask - The key attribute mask is not valid.",
errSecUnsupportedKeyAttributeMask: "errSecUnsupportedKeyAttributeMask - The key attribute mask is not supported.",
errSecInvalidKeyLabel: "errSecInvalidKeyLabel - The key label is not valid.",
errSecUnsupportedKeyLabel: "errSecUnsupportedKeyLabel - The key label is not supported.",
errSecInvalidKeyFormat: "errSecInvalidKeyFormat - The key format is not valid.",
errSecUnsupportedVectorOfBuffers: "errSecUnsupportedVectorOfBuffers - The vector of buffers is not supported.",
errSecInvalidInputVector: "errSecInvalidInputVector - The input vector is not valid.",
errSecInvalidOutputVector: "errSecInvalidOutputVector - The output vector is not valid.",
errSecInvalidContext: "errSecInvalidContext - An invalid context was encountered.",
errSecInvalidAlgorithm: "errSecInvalidAlgorithm - An invalid algorithm was encountered.",
errSecInvalidAttributeKey: "errSecInvalidAttributeKey - A key attribute was not valid.",
errSecMissingAttributeKey: "errSecMissingAttributeKey - A key attribute was missing.",
errSecInvalidAttributeInitVector: "errSecInvalidAttributeInitVector - An init vector attribute was not valid.",
errSecMissingAttributeInitVector: "errSecMissingAttributeInitVector - An init vector attribute was missing.",
errSecInvalidAttributeSalt: "errSecInvalidAttributeSalt - A salt attribute was not valid.",
errSecMissingAttributeSalt: "errSecMissingAttributeSalt - A salt attribute was missing.",
errSecInvalidAttributePadding: "errSecInvalidAttributePadding - A padding attribute was not valid.",
errSecMissingAttributePadding: "errSecMissingAttributePadding - A padding attribute was missing.",
errSecInvalidAttributeRandom: "errSecInvalidAttributeRandom - A random number attribute was not valid.",
errSecMissingAttributeRandom: "errSecMissingAttributeRandom - A random number attribute was missing.",
errSecInvalidAttributeSeed: "errSecInvalidAttributeSeed - A seed attribute was not valid.",
errSecMissingAttributeSeed: "errSecMissingAttributeSeed - A seed attribute was missing.",
errSecInvalidAttributePassphrase: "errSecInvalidAttributePassphrase - A passphrase attribute was not valid.",
errSecMissingAttributePassphrase: "errSecMissingAttributePassphrase - A passphrase attribute was missing.",
errSecInvalidAttributeKeyLength: "errSecInvalidAttributeKeyLength - A key length attribute was not valid.",
errSecMissingAttributeKeyLength: "errSecMissingAttributeKeyLength - A key length attribute was missing.",
errSecInvalidAttributeBlockSize: "errSecInvalidAttributeBlockSize - A block size attribute was not valid.",
errSecMissingAttributeBlockSize: "errSecMissingAttributeBlockSize - A block size attribute was missing.",
errSecInvalidAttributeOutputSize: "errSecInvalidAttributeOutputSize - An output size attribute was not valid.",
errSecMissingAttributeOutputSize: "errSecMissingAttributeOutputSize - An output size attribute was missing.",
errSecInvalidAttributeRounds: "errSecInvalidAttributeRounds - The number of rounds attribute was not valid.",
errSecMissingAttributeRounds: "errSecMissingAttributeRounds - The number of rounds attribute was missing.",
errSecInvalidAlgorithmParms: "errSecInvalidAlgorithmParms - An algorithm parameters attribute was not valid.",
errSecMissingAlgorithmParms: "errSecMissingAlgorithmParms - An algorithm parameters attribute was missing.",
errSecInvalidAttributeLabel: "errSecInvalidAttributeLabel - A label attribute was not valid.",
errSecMissingAttributeLabel: "errSecMissingAttributeLabel - A label attribute was missing.",
errSecInvalidAttributeKeyType: "errSecInvalidAttributeKeyType - A key type attribute was not valid.",
errSecMissingAttributeKeyType: "errSecMissingAttributeKeyType - A key type attribute was missing.",
errSecInvalidAttributeMode: "errSecInvalidAttributeMode - A mode attribute was not valid.",
errSecMissingAttributeMode: "errSecMissingAttributeMode - A mode attribute was missing.",
errSecInvalidAttributeEffectiveBits: "errSecInvalidAttributeEffectiveBits - An effective bits attribute was not valid.",
errSecMissingAttributeEffectiveBits: "errSecMissingAttributeEffectiveBits - An effective bits attribute was missing.",
errSecInvalidAttributeStartDate: "errSecInvalidAttributeStartDate - A start date attribute was not valid.",
errSecMissingAttributeStartDate: "errSecMissingAttributeStartDate - A start date attribute was missing.",
errSecInvalidAttributeEndDate: "errSecInvalidAttributeEndDate - An end date attribute was not valid.",
errSecMissingAttributeEndDate: "errSecMissingAttributeEndDate - An end date attribute was missing.",
errSecInvalidAttributeVersion: "errSecInvalidAttributeVersion - A version attribute was not valid.",
errSecMissingAttributeVersion: "errSecMissingAttributeVersion - A version attribute was missing.",
errSecInvalidAttributePrime: "errSecInvalidAttributePrime - A prime attribute was not valid.",
errSecMissingAttributePrime: "errSecMissingAttributePrime - A prime attribute was missing.",
errSecInvalidAttributeBase: "errSecInvalidAttributeBase - A base attribute was not valid.",
errSecMissingAttributeBase: "errSecMissingAttributeBase - A base attribute was missing.",
errSecInvalidAttributeSubprime: "errSecInvalidAttributeSubprime - A subprime attribute was not valid.",
errSecMissingAttributeSubprime: "errSecMissingAttributeSubprime - A subprime attribute was missing.",
errSecInvalidAttributeIterationCount: "errSecInvalidAttributeIterationCount - An iteration count attribute was not valid.",
errSecMissingAttributeIterationCount: "errSecMissingAttributeIterationCount - An iteration count attribute was missing.",
errSecInvalidAttributeDLDBHandle: "errSecInvalidAttributeDLDBHandle - A database handle attribute was not valid.",
errSecMissingAttributeDLDBHandle: "errSecMissingAttributeDLDBHandle - A database handle attribute was missing.",
errSecInvalidAttributeAccessCredentials: "errSecInvalidAttributeAccessCredentials - An access credentials attribute was not valid.",
errSecMissingAttributeAccessCredentials: "errSecMissingAttributeAccessCredentials - An access credentials attribute was missing.",
errSecInvalidAttributePublicKeyFormat: "errSecInvalidAttributePublicKeyFormat - A public key format attribute was not valid.",
errSecMissingAttributePublicKeyFormat: "errSecMissingAttributePublicKeyFormat - A public key format attribute was missing.",
errSecInvalidAttributePrivateKeyFormat: "errSecInvalidAttributePrivateKeyFormat - A private key format attribute was not valid.",
errSecMissingAttributePrivateKeyFormat: "errSecMissingAttributePrivateKeyFormat - A private key format attribute was missing.",
errSecInvalidAttributeSymmetricKeyFormat: "errSecInvalidAttributeSymmetricKeyFormat - A symmetric key format attribute was not valid.",
errSecMissingAttributeSymmetricKeyFormat: "errSecMissingAttributeSymmetricKeyFormat - A symmetric key format attribute was missing.",
errSecInvalidAttributeWrappedKeyFormat: "errSecInvalidAttributeWrappedKeyFormat - A wrapped key format attribute was not valid.",
errSecMissingAttributeWrappedKeyFormat: "errSecMissingAttributeWrappedKeyFormat - A wrapped key format attribute was missing.",
errSecStagedOperationInProgress: "errSecStagedOperationInProgress - A staged operation is in progress.",
errSecStagedOperationNotStarted: "errSecStagedOperationNotStarted - A staged operation was not started.",
errSecVerifyFailed: "errSecVerifyFailed - A cryptographic verification failure has occurred.",
errSecQuerySizeUnknown: "errSecQuerySizeUnknown - The query size is unknown.",
errSecBlockSizeMismatch: "errSecBlockSizeMismatch - A block size mismatch occurred.",
errSecPublicKeyInconsistent: "errSecPublicKeyInconsistent - The public key was inconsistent.",
errSecDeviceVerifyFailed: "errSecDeviceVerifyFailed - A device verification failure has occurred.",
errSecInvalidLoginName: "errSecInvalidLoginName - An invalid login name was detected.",
errSecAlreadyLoggedIn: "errSecAlreadyLoggedIn - The user is already logged in.",
errSecInvalidDigestAlgorithm: "errSecInvalidDigestAlgorithm - An invalid digest algorithm was detected.",
errSecInvalidCRLGroup: "errSecInvalidCRLGroup - An invalid CRL group was detected.",
errSecCertificateCannotOperate: "errSecCertificateCannotOperate - The certificate cannot operate.",
errSecCertificateExpired: "errSecCertificateExpired - An expired certificate was detected.",
errSecCertificateNotValidYet: "errSecCertificateNotValidYet - The certificate is not yet valid.",
errSecCertificateRevoked: "errSecCertificateRevoked - The certificate was revoked.",
errSecCertificateSuspended: "errSecCertificateSuspended - The certificate was suspended.",
errSecInsufficientCredentials: "errSecInsufficientCredentials - Insufficient credentials were detected.",
errSecInvalidAction: "errSecInvalidAction - The action was not valid.",
errSecInvalidAuthority: "errSecInvalidAuthority - The authority was not valid.",
errSecVerifyActionFailed: "errSecVerifyActionFailed - A verify action has failed.",
errSecInvalidCertAuthority: "errSecInvalidCertAuthority - The certificate authority was not valid.",
errSecInvaldCRLAuthority: "errSecInvaldCRLAuthority - The CRL authority was not valid.",
errSecInvalidCRLEncoding: "errSecInvalidCRLEncoding - The CRL encoding was not valid.",
errSecInvalidCRLType: "errSecInvalidCRLType - The CRL type was not valid.",
errSecInvalidCRL: "errSecInvalidCRL - The CRL was not valid.",
errSecInvalidFormType: "errSecInvalidFormType - The form type was not valid.",
errSecInvalidID: "errSecInvalidID - The ID was not valid.",
errSecInvalidIdentifier: "errSecInvalidIdentifier - The identifier was not valid.",
errSecInvalidIndex: "errSecInvalidIndex - The index was not valid.",
errSecInvalidPolicyIdentifiers: "errSecInvalidPolicyIdentifiers - The policy identifiers are not valid.",
errSecInvalidTimeString: "errSecInvalidTimeString - The time specified was not valid.",
errSecInvalidReason: "errSecInvalidReason - The trust policy reason was not valid.",
errSecInvalidRequestInputs: "errSecInvalidRequestInputs - The request inputs are not valid.",
errSecInvalidResponseVector: "errSecInvalidResponseVector - The response vector was not valid.",
errSecInvalidStopOnPolicy: "errSecInvalidStopOnPolicy - The stop-on policy was not valid.",
errSecInvalidTuple: "errSecInvalidTuple - The tuple was not valid.",
errSecMultipleValuesUnsupported: "errSecMultipleValuesUnsupported - Multiple values are not supported.",
errSecNotTrusted: "errSecNotTrusted - The trust policy was not trusted.",
errSecNoDefaultAuthority: "errSecNoDefaultAuthority - No default authority was detected.",
errSecRejectedForm: "errSecRejectedForm - The trust policy had a rejected form.",
errSecRequestLost: "errSecRequestLost - The request was lost.",
errSecRequestRejected: "errSecRequestRejected - The request was rejected.",
errSecUnsupportedAddressType: "errSecUnsupportedAddressType - The address type is not supported.",
errSecUnsupportedService: "errSecUnsupportedService - The service is not supported.",
errSecInvalidTupleGroup: "errSecInvalidTupleGroup - The tuple group was not valid.",
errSecInvalidBaseACLs: "errSecInvalidBaseACLs - The base ACLs are not valid.",
errSecInvalidTupleCredendtials: "errSecInvalidTupleCredendtials - The tuple credentials are not valid.",
errSecInvalidEncoding: "errSecInvalidEncoding - The encoding was not valid.",
errSecInvalidValidityPeriod: "errSecInvalidValidityPeriod - The validity period was not valid.",
errSecInvalidRequestor: "errSecInvalidRequestor - The requestor was not valid.",
errSecRequestDescriptor: "errSecRequestDescriptor - The request descriptor was not valid.",
errSecInvalidBundleInfo: "errSecInvalidBundleInfo - The bundle information was not valid.",
errSecInvalidCRLIndex: "errSecInvalidCRLIndex - The CRL index was not valid.",
errSecNoFieldValues: "errSecNoFieldValues - No field values were detected.",
errSecUnsupportedFieldFormat: "errSecUnsupportedFieldFormat - The field format is not supported.",
errSecUnsupportedIndexInfo: "errSecUnsupportedIndexInfo - The index information is not supported.",
errSecUnsupportedLocality: "errSecUnsupportedLocality - The locality is not supported.",
errSecUnsupportedNumAttributes: "errSecUnsupportedNumAttributes - The number of attributes is not supported.",
errSecUnsupportedNumIndexes: "errSecUnsupportedNumIndexes - The number of indexes is not supported.",
errSecUnsupportedNumRecordTypes: "errSecUnsupportedNumRecordTypes - The number of record types is not supported.",
errSecFieldSpecifiedMultiple: "errSecFieldSpecifiedMultiple - Too many fields were specified.",
errSecIncompatibleFieldFormat: "errSecIncompatibleFieldFormat - The field format was incompatible.",
errSecInvalidParsingModule: "errSecInvalidParsingModule - The parsing module was not valid.",
errSecDatabaseLocked: "errSecDatabaseLocked - The database is locked.",
errSecDatastoreIsOpen: "errSecDatastoreIsOpen - The data store is open.",
errSecMissingValue: "errSecMissingValue - A missing value was detected.",
errSecUnsupportedQueryLimits: "errSecUnsupportedQueryLimits - The query limits are not supported.",
errSecUnsupportedNumSelectionPreds: "errSecUnsupportedNumSelectionPreds - The number of selection predicates is not supported.",
errSecUnsupportedOperator: "errSecUnsupportedOperator - The operator is not supported.",
errSecInvalidDBLocation: "errSecInvalidDBLocation - The database location is not valid.",
errSecInvalidAccessRequest: "errSecInvalidAccessRequest - The access request is not valid.",
errSecInvalidIndexInfo: "errSecInvalidIndexInfo - The index information is not valid.",
errSecInvalidNewOwner: "errSecInvalidNewOwner - The new owner is not valid.",
errSecInvalidModifyMode: "errSecInvalidModifyMode - The modify mode is not valid.",
errSecMissingRequiredExtension: "errSecMissingRequiredExtension - A required certificate extension is missing.",
errSecExtendedKeyUsageNotCritical: "errSecExtendedKeyUsageNotCritical - The extended key usage extension was not marked critical.",
errSecTimestampMissing: "errSecTimestampMissing - A timestamp was expected but was not found.",
errSecTimestampInvalid: "errSecTimestampInvalid - The timestamp was not valid.",
errSecTimestampNotTrusted: "errSecTimestampNotTrusted - The timestamp was not trusted.",
errSecTimestampServiceNotAvailable: "errSecTimestampServiceNotAvailable - The timestamp service is not available.",
errSecTimestampBadAlg: "errSecTimestampBadAlg - An unrecognized or unsupported Algorithm Identifier in timestamp.",
errSecTimestampBadRequest: "errSecTimestampBadRequest - The timestamp transaction is not permitted or supported.",
errSecTimestampBadDataFormat: "errSecTimestampBadDataFormat - The timestamp data submitted has the wrong format.",
errSecTimestampTimeNotAvailable: "errSecTimestampTimeNotAvailable - The time source for the Timestamp Authority is not available.",
errSecTimestampUnacceptedPolicy: "errSecTimestampUnacceptedPolicy - The requested policy is not supported by the Timestamp Authority.",
errSecTimestampUnacceptedExtension: "errSecTimestampUnacceptedExtension - The requested extension is not supported by the Timestamp Authority.",
errSecTimestampAddInfoNotAvailable: "errSecTimestampAddInfoNotAvailable - The additional information requested is not available.",
errSecTimestampSystemFailure: "errSecTimestampSystemFailure - The timestamp request cannot be handled due to system failure.",
errSecSigningTimeMissing: "errSecSigningTimeMissing - A signing time was expected but was not found.",
errSecTimestampRejection: "errSecTimestampRejection - A timestamp transaction was rejected.",
errSecTimestampWaiting: "errSecTimestampWaiting - A timestamp transaction is waiting.",
errSecTimestampRevocationWarning: "errSecTimestampRevocationWarning - A timestamp authority revocation warning was issued.",
errSecTimestampRevocationNotification: "errSecTimestampRevocationNotification - A timestamp authority revocation notification was issued."
]
func OSStatusGetErrorCodeMessage(_ status: OSStatus) -> String {
return OSStatusErrorCodeMessageMapping[status] ?? "Unknown Status \(status)"
}
func OSStatusGetError(_ status: OSStatus) -> Error {
return NSError(domain: NSOSStatusErrorDomain, code: Int(status), userInfo: [NSLocalizedDescriptionKey: NSLocalizedString(OSStatusGetErrorCodeMessage(status), comment: "")])
}
#!/usr/bin/swift
//https://gist.github.com/KoCMoHaBTa/d90dd89c5af4f194848486e78fd39f96
import Foundation
/*
Converts the following kind of lines:
public var errSecNotAvailable: OSStatus { get } /* No keychain is available. You may need to restart your computer. */
into:
errSecNotAvailable: "errSecNotAvailable - No keychain is available. You may need to restart your computer.",
*/
let inputPath = CommandLine.arguments[1]
let outputPath = CommandLine.arguments[2]
let inputContents = try! String(contentsOfFile: inputPath)
let lines = inputContents.components(separatedBy: "\n").map { (line) -> String in
guard line != "" else {
return line
}
let components = line.components(separatedBy: ":")
let name = components.first!.replacingOccurrences(of: "public var ", with: "")
let description = components.last!.replacingOccurrences(of: " OSStatus { get } /* ", with: "").replacingOccurrences(of: " */", with: "").replacingOccurrences(of: " OSStatus { get } /*", with: "").replacingOccurrences(of: "*/", with: "").replacingOccurrences(of: " OSStatus { get }", with: "")
var result = ""
result = result + name + ": " + "\"" + name
if description != "" {
result = result + " - " + description
}
result = result + "\""
return result
}
let outputContents = lines.joined(separator: ",\n").replacingOccurrences(of: "\n,\n", with: "\n\n")
try! outputContents.write(toFile: outputPath, atomically: true, encoding: .utf8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment