【问题标题】:iOS CommonCrypto reference [closed]iOS CommonCrypto 参考 [关闭]
【发布时间】:2013-05-17 06:32:58
【问题描述】:

我正在尝试为 Apple 的 CommonCrypto 库查找某种参考,因为显然 Apple 没有任何明显的链接,而且 Google 提供的链接已经过时,如下所示:

https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/Common%20Crypto.3cc.html

对此有任何提示吗?有没有更好的库可以用来开发具有大量加密功能的应用程序?

谢谢。

【问题讨论】:

  • 是的,我也有同样的问题。找不到任何关于 CommonCrypto 的信息
  • 问题中的链接包含指向各种加密原语的链接。喜欢的页面底部是指向:CC_MD5、CC_SHA、CCHmac、CCCryptor 的链接。
  • 您是否拥有丰富的加密经验与“大量加密功能”相关?
  • CommonCrypto 的链接坏了。

标签: ios documentation cryptography commoncrypto


【解决方案1】:

有一个很好的示例项目,名为CryptoCompatibility,您可以通过 Xcode 找到并下载它。与其只看头文件,不如从中学习。只需在“文档和 API 参考”窗口中搜索即可。

【讨论】:

    【解决方案2】:

    他们提供的大部分信息都在头文件的开始行中。按住 Command 键盘按钮并抬起单击 CommonCrypto/CommonCryptor.h 以访问它。

    /*!
    @header     CommonCryptor.h
    @abstract   Generic interface for symmetric encryption. 
    
    @discussion This interface provides access to a number of symmetric 
                encryption algorithms. Symmetric encryption algorithms come 
                in two "flavors" -  block ciphers, and stream ciphers. Block
                ciphers process data (while both encrypting and decrypting) 
                in discrete chunks of  data called blocks; stream ciphers 
                operate on arbitrary sized data. 
    
                The object declared in this interface, CCCryptor, provides
                access to both block ciphers and stream ciphers with the same
                API; however some options are available for block ciphers that
                do not apply to stream ciphers. 
    
                The general operation of a CCCryptor is: initialize it
                with raw key data and other optional fields with
                CCCryptorCreate(); process input data via one or more calls to
                CCCryptorUpdate(), each of which may result in output data
                being written to caller-supplied memory; and obtain possible
                remaining output data with CCCryptorFinal(). The CCCryptor is
                disposed of via CCCryptorRelease(), or it can be reused (with
                the same key data as provided to CCCryptorCreate()) by calling
                CCCryptorReset(). 
    
                CCCryptors can be dynamically allocated by this module, or 
                their memory can be allocated by the caller. See discussion for
                CCCryptorCreate() and CCCryptorCreateFromData() for information 
                on CCCryptor allocation.
    
                One option for block ciphers is padding, as defined in PKCS7;
                when padding is enabled, the total amount of data encrypted
                does not have to be an even multiple of the block size, and 
                the actual length of plaintext is calculated during decryption. 
    
                Another option for block ciphers is Cipher Block Chaining, known
                as CBC mode. When using CBC mode, an Initialization Vector (IV)
                is provided along with the key when starting an encrypt
                or decrypt operation. If CBC mode is selected and no IV is 
                provided, an IV of all zeroes will be used. 
    
                CCCryptor also implements block bufferring, so that individual
                calls to CCCryptorUpdate() do not have to provide data whose
                length is aligned to the block size. (If padding is disabled,
                encrypting with block ciphers does require that the *total*
                length of data input to CCCryptorUpdate() call(s) be aligned
                to the block size.)
    
                A given CCCryptor can only be used by one thread at a time;
                multiple threads can use safely different CCCryptors at the
                same time.              
    */
    

    【讨论】:

    • 感谢您的回答!
    猜你喜欢
    • 1970-01-01
    • 2012-11-22
    • 2010-10-26
    • 2014-09-10
    • 2011-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多