#[repr(C)]pub struct SecCode { /* private fields */ }
CSCommon
only.Expand description
This is the type of a reference to running code.
In many (but not all) calls, this can be passed to a SecStaticCodeRef argument, which performs an implicit SecCodeCopyStaticCode call and operates on the result.
See also Apple’s documentation
Implementations§
Source§impl SecCode
impl SecCode
Sourcepub unsafe fn copy_self(flags: SecCSFlags, self_: NonNull<*mut SecCode>) -> i32
Available on crate feature SecCode
only.
pub unsafe fn copy_self(flags: SecCSFlags, self_: NonNull<*mut SecCode>) -> i32
SecCode
only.Obtains a SecCode object for the code making the call. The calling code is determined in a way that is subject to modification over time, but obeys the following rules. If it is a UNIX process, its process id (pid) is always used.
Parameter flags
: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
Parameter self
: Upon successful return, contains a SecCodeRef representing the caller.
Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in CSCommon.h or certain other Security framework headers.
Source§impl SecCode
impl SecCode
pub unsafe fn copy_static_code( self: &SecCode, flags: SecCSFlags, static_code: NonNull<*const SecStaticCode>, ) -> i32
SecCode
only.Sourcepub unsafe fn copy_host(
self: &SecCode,
flags: SecCSFlags,
host: NonNull<*mut SecCode>,
) -> i32
Available on crate feature SecCode
only.
pub unsafe fn copy_host( self: &SecCode, flags: SecCSFlags, host: NonNull<*mut SecCode>, ) -> i32
SecCode
only.Given a SecCode object, identify the (different) SecCode object that acts as its host. A SecCode’s host acts as a supervisor and controller, and is the ultimate authority on the its dynamic validity and status. The host relationship is securely established (absent reported errors).
Parameter guest
: A valid SecCode object reference representing code running
on the system.
Parameter flags
: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
Parameter host
: On successful return, a SecCode object reference identifying
the code’s host.
Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in CSCommon.h or certain other Security framework headers.
Source§impl SecCode
impl SecCode
Sourcepub unsafe fn copy_guest_with_attributes(
host: Option<&SecCode>,
attributes: Option<&CFDictionary>,
flags: SecCSFlags,
guest: NonNull<*mut SecCode>,
) -> i32
Available on crate feature SecCode
only.
pub unsafe fn copy_guest_with_attributes( host: Option<&SecCode>, attributes: Option<&CFDictionary>, flags: SecCSFlags, guest: NonNull<*mut SecCode>, ) -> i32
SecCode
only.This is the omnibus API function for obtaining dynamic code references. In general, it asks a particular code acting as a code host to locate and return a guest with given attributes. Different hosts support different combinations of attributes and values for guest selection.
Asking the NULL host invokes system default procedures for obtaining any running code in the system with the attributes given. The returned code may be anywhere in the system.
The methods a host uses to identify, separate, and control its guests are specific to each type of host. This call provides a generic abstraction layer that allows uniform interrogation of all hosts. A SecCode that does not act as a host will always return errSecCSNoSuchCode. A SecCode that does support hosting may return itself to signify that the attribute refers to itself rather than one of its hosts.
Parameter host
: A valid SecCode object reference representing code running
on the system that acts as a Code Signing host. As a special case, passing
NULL indicates that the Code Signing root of trust should be used as a starting
point. Currently, that is the system kernel.
Parameter attributes
: A CFDictionary containing zero or more attribute selector
values. Each selector has a CFString key and associated CFTypeRef value.
The key name identifies the attribute being specified; the associated value,
whose type depends on the the key name, selects a particular value or other
constraint on that attribute. Each host only supports particular combinations
of keys and values, and errors will be returned if any unsupported set is requested.
As a special case, NULL is taken to mean an empty attribute set.
Note that some hosts that support hosting chains (guests being hosts)
may return sub-guests in this call. In other words, do not assume that
a SecCodeRef returned by this call is a direct guest of the queried host
(though it will be a proximate guest, i.e. a guest’s guest some way down).
Asking the NULL host for NULL attributes returns a code reference for the system root
of trust (at present, the running Darwin kernel).
Parameter flags
: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
Parameter guest
: On successful return, a SecCode object reference identifying
the particular guest of the host that owns the attribute value(s) specified.
This argument will not be changed if the call fails (does not return errSecSuccess).
Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in CSCommon.h or certain other Security framework headers. In particular: errSecCSUnsupportedGuestAttributes The host does not support the attribute type given by attributeType. errSecCSInvalidAttributeValues The type of value given for a guest attribute is not supported by the host. errSecCSNoSuchCode The host has no guest with the attribute value given by attributeValue, even though the value is of a supported type. This may also be returned if the host code does not currently act as a Code Signing host. errSecCSNotAHost The specified host cannot, in fact, act as a code host. (It is missing the kSecCodeSignatureHost option flag in its code signature.) errSecCSMultipleGuests The attributes specified do not uniquely identify a guest (the specification is ambiguous).
Sourcepub unsafe fn check_validity(
self: &SecCode,
flags: SecCSFlags,
requirement: Option<&SecRequirement>,
) -> i32
Available on crate feature SecCode
only.
pub unsafe fn check_validity( self: &SecCode, flags: SecCSFlags, requirement: Option<&SecRequirement>, ) -> i32
SecCode
only.Performs dynamic validation of the given SecCode object. The call obtains and verifies the signature on the code object. It checks the validity of only those sealed components required to establish identity. It checks the SecCode’s dynamic validity status as reported by its host. It ensures that the SecCode’s host is in turn valid. Finally, it validates the code against a SecRequirement if one is given. The call succeeds if all these conditions are satisfactory. It fails otherwise.
This call is secure against attempts to modify the file system source of the SecCode.
Parameter code
: The code object to be validated.
Parameter flags
: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
Parameter requirement
: An optional code requirement specifying additional conditions
the code object must satisfy to be considered valid. If NULL, no additional
requirements are imposed.
Returns: If validation passes, errSecSuccess. If validation fails, an OSStatus value documented in CSCommon.h or certain other Security framework headers.
Sourcepub unsafe fn check_validity_with_errors(
self: &SecCode,
flags: SecCSFlags,
requirement: Option<&SecRequirement>,
errors: *mut *mut CFError,
) -> i32
Available on crate feature SecCode
only.
pub unsafe fn check_validity_with_errors( self: &SecCode, flags: SecCSFlags, requirement: Option<&SecRequirement>, errors: *mut *mut CFError, ) -> i32
SecCode
only.Performs dynamic validation of the given SecCode object. The call obtains and verifies the signature on the code object. It checks the validity of only those sealed components required to establish identity. It checks the SecCode’s dynamic validity status as reported by its host. It ensures that the SecCode’s host is in turn valid. Finally, it validates the code against a SecRequirement if one is given. The call succeeds if all these conditions are satisfactory. It fails otherwise.
This call is secure against attempts to modify the file system source of the SecCode.
Parameter code
: The code object to be validated.
Parameter flags
: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
Parameter requirement
: An optional code requirement specifying additional conditions
the code object must satisfy to be considered valid. If NULL, no additional
requirements are imposed.
Parameter errors
: An optional pointer to a CFErrorRef variable. If the call fails
(and something other than errSecSuccess is returned), and this argument is non-NULL,
a CFErrorRef is stored there further describing the nature and circumstances
of the failure. The caller must CFRelease() this error object when done with it.
Returns: If validation passes, errSecSuccess. If validation fails, an OSStatus value documented in CSCommon.h or certain other Security framework headers.
Sourcepub unsafe fn validate_file_resource(
code: &SecStaticCode,
relative_path: &CFString,
file_data: &CFData,
flags: SecCSFlags,
) -> i32
Available on crate feature SecCode
only.
pub unsafe fn validate_file_resource( code: &SecStaticCode, relative_path: &CFString, file_data: &CFData, flags: SecCSFlags, ) -> i32
SecCode
only.For a SecStaticCodeRef, check that a given CFData object faithfully represents a plain-file resource in its resource seal. This call will fail if the file is missing in the bundle, even if it is optional.
Parameter code
: A code or StaticCode object.
Parameter relativePath
: A CFStringRef containing the relative path to a sealed resource
file. This path is relative to the resource base, which is either Contents or
the bundle root, depending on bundle format.
Parameter fileData
: A CFDataRef containing the exact contents of that resource file.
Parameter flags
: Pass kSecCSDefaultFlags.
Returns: noErr if fileData is the exact content of the file at relativePath at the time it was signed. Various error codes if it is different, there was no such file, it was not a plain file, or anything is irregular.
Sourcepub unsafe fn copy_path(
static_code: &SecStaticCode,
flags: SecCSFlags,
path: NonNull<*const CFURL>,
) -> i32
Available on crate feature SecCode
only.
pub unsafe fn copy_path( static_code: &SecStaticCode, flags: SecCSFlags, path: NonNull<*const CFURL>, ) -> i32
SecCode
only.For a given Code or StaticCode object, returns a URL to a location on disk where the code object can be found. For single files, the URL points to that file. For bundles, it points to the directory containing the entire bundle.
Parameter staticCode
: The Code or StaticCode object to be located. For a Code
argument, its StaticCode is processed as per SecCodeCopyStaticCode.
Parameter flags
: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
Parameter path
: On successful return, contains a CFURL identifying the location
on disk of the staticCode object.
Returns: On success, errSecSuccess. On error, an OSStatus value documented in CSCommon.h or certain other Security framework headers.
Sourcepub unsafe fn copy_designated_requirement(
code: &SecStaticCode,
flags: SecCSFlags,
requirement: NonNull<*mut SecRequirement>,
) -> i32
Available on crate feature SecCode
only.
pub unsafe fn copy_designated_requirement( code: &SecStaticCode, flags: SecCSFlags, requirement: NonNull<*mut SecRequirement>, ) -> i32
SecCode
only.For a given Code or StaticCode object, determines its Designated Code Requirement. The Designated Requirement is the SecRequirement that the code believes should be used to properly identify it in the future.
If the SecCode contains an explicit Designated Requirement, a copy of that is returned. If it does not, a SecRequirement is implicitly constructed from its signing authority and its embedded unique identifier. No Designated Requirement can be obtained from code that is unsigned. Code that is modified after signature, improperly signed, or has become invalid, may or may not yield a Designated Requirement. This call does not validate the SecStaticCode argument.
Parameter code
: The Code or StaticCode object to be interrogated. For a Code
argument, its StaticCode is processed as per SecCodeCopyStaticCode.
Parameter flags
: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
Parameter requirement
: On successful return, contains a copy of a SecRequirement
object representing the code’s Designated Requirement. On error, unchanged.
Returns: On success, errSecSuccess. On error, an OSStatus value documented in CSCommon.h or certain other Security framework headers.
Source§impl SecCode
impl SecCode
pub unsafe fn copy_signing_information( code: &SecStaticCode, flags: SecCSFlags, information: NonNull<*const CFDictionary>, ) -> i32
SecCode
only.pub unsafe fn map_memory(code: &SecStaticCode, flags: SecCSFlags) -> i32
SecCode
only.Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate feature SecCustomTransform
only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
SecCustomTransform
only.Attempt to downcast the type to that of type T
.
This is the reference-variant. Use CFRetained::downcast
if you
want to convert a retained type. See also ConcreteType
for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
Available on crate feature SecCustomTransform
only.
pub fn retain_count(&self) -> usize
SecCustomTransform
only.Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumber
s, small CFString
s etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX
in that case.
Trait Implementations§
Source§impl ConcreteType for SecCode
Available on crate feature SecCode
only.
impl ConcreteType for SecCode
SecCode
only.Source§impl RefEncode for SecCode
impl RefEncode for SecCode
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for SecCode
impl Type for SecCode
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation
crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation
crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation
crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation
crate. Read more