Library/Keychains/*.keychain: No such file or directory

The codesigning keychain appears to be locked!
ls: /Users/P2723369/Library/Keychains/*.keychain: No such file or directory
error 1: no valid keychains found!

Starting January 28, 2021, the digital certificates you use to sign your software for installation on Apple devices, submit apps to the App Store, and connect to certain Apple services will be issued from the new intermediate Apple Worldwide Developer Relations certificate that expires on February 20, 2030. Learn how to prepare for the new intermediate certificate.

  • Launch Keychain Access and delete the application certificate and any “Apple Worldwide Developer Relations Certification Authority” certificates.
  • 2)  Install the application certificate and install the “Worldwide Developer Relations” certificates that expires in 2023 and 2030 from https://www.apple.com/certificateauthority/.

iOS: Create Password Protected Zip File

Source: https://code.google.com/archive/p/ziparchive/

NSString *filePath = @"/Users//Desktop/uf/abc.txt";
NSString *zipFilePath = @"/Users//Desktop/uf/abc.zip";
NSString *content = @"Contents to be stored";

NSError *error = nil;
BOOL isFileCreated = [content writeToFile:filePath atomically:YES encoding:NSASCIIStringEncoding error:&error];

if (isFileCreated)
{
    ZipArchive *zipArchive = [[ZipArchive alloc] init];
    BOOL isZipFileCreated = [zipArchive CreateZipFile2:zipFilePath Password:@"domle"];

    if (isZipFileCreated)
    {
       BOOL isFileAddedToZip = [zipArchive addFileToZip:filePath newname:[filePath lastPathComponent]];
       NSLog(@"isFileAddedToZipFile %d", isFileAddedToZip);
       [zipArchive CloseZipFile2];
    }
}

 

 

iOS AES128 Encryption and Decryption

Why I am giving the following steps instead of direct link is. The link is changing frequently I guess or they are updating the article or code itself. I saw the method names got changed.

Follow the steps.

  1. Go to http://iphonedevcentral.blogspot.in.
  2. Top left corner, you see search box. Search for Strong Encryption.
  3. Read the article and down the data from the link provided.

 

Code:

kCCOptionECBMode : Electronic Code Book (ECB). Electronic Code Book (ECB) is a mode of operation for a block cipher, with the characteristic that each possible block of plaintext has a defined corresponding ciphertext value and vice versa. In other words, the same plaintext value will always result in the same ciphertext value. Electronic Code Book is used when a volume of plaintext is separated into several blocks of data, each of which is then encrypted independently of other blocks. In fact, Electronic Code Book has the ability to support a separate encryption key for each block type.

Cited the above definition from http://searchsecurity.techtarget.com/definition/Electronic-Code-Book.

CCCrypt is the apple api that actually encrypts or decrypts based on the parameters passed to it.

kCCAlgorithmAES128 is the algorithm to use to encrypt or decrypt. It will successfully encrypt or decrypt only 15 characters, because the buffer size accepts 16 characters. Last character space is for termination character ‘\0’.

If you send more than 15 characters then you will face issue in decryption. So in order to encrypt more than 15 characters then you need to pass kCCOptionECBMode in options. That will internally split the characters and encrypt and provide you the result. In decryption also you mention this mode.

   CCCryptorStatus cryptStatus = CCCrypt( kCCEncrypt, kCCAlgorithmAES128, kCCOptionECBMode + kCCOptionPKCS7Padding,

                                          keyPtr, kCCKeySizeAES256,

                                          NULL /* initialization vector (optional) */,

                                          [self bytes], dataLength, /* input */

                                          buffer, bufferSize, /* output */

                                          &numBytesEncrypted );

Useful Links:

  1. https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
  2. https://de.wikipedia.org/wiki/Electronic_Code_Book_Mode
  3. https://www.tutorialspoint.com/cryptography/block_cipher_modes_of_operation.htm

IOS Coding Tips for Beginners

1. Create view objects in Interface builder not in source code.

2. Flower brackets always be there in if conditions or while loops, even it has single statement.

3. Give one line space between @implementation and @synthesize

4. Open flower bracket “{” should start in next line.

5. Give one line space above conditional or loop statements like if, while, for.

6. The method name itself should resembles its behavior.

7. Remove unnecessary methods which are created by the file templates.

8. Use Edit->Format->Re-Indent to re-indent the selection of statements.

9. Don’t use string literals as keys, make the string literal as constant and use that. Place all constants in a common file.

10. Try to use property directly than calling the accessory method. for example Object.memberVariable than [Object memberVariable];

11. Try to define all literals in common file.

12. Instead of using literals, create meaningful constants for them in common file and use them.

13. Always group the things like constants, statements, etc.

14. The format for method signature should be like
– (void) methodName:(id) sender;

15. One line space between logical group of statements and two lines between physical groups.

16. Try to eliminate autorelease objects, instead use retain and release.

17. If you are declaring a UI object, please suffix the type to the variable. For example, if you are declaring a UILabel object with name ‘userName’, then name it ‘userNameLabel’.

18. Maintain all image names in lowercase with underscore dividing the inline words.

19. Directly access the variable instead of using property in the same class. For example, don’t access

UITableView mTableView;
@Property () UITableView *tableView;
//To reload the table in the same class use
[mTableView reloadData]; // correct
[self.tableView reloadData]; //wrong

CoreTelephony CTCallCenter

The [[CTCallCenter alloc] init] must be run in the main queue. Is it thread safe ??? Better call it on main thread only.

There is an iOS bug that causes instances of the CTCallCenter class to sometimes get notifications after they have been deallocated. Instead of instantiating, using, and releasing instances you must instead retain and never release them to work around the bug.

static CTCallCenter *netInfo; static dispatch_once_t dispatchToken; if (!netInfo) { dispatch_once(&dispatchToken, ^{ netInfo = [[CTCallCenter alloc] init]; }); }