210524 Mon

Sunny·2021년 6월 2일
0

Today I Learned

목록 보기
61/88

키체인이란 무엇일까?

Securely store small chunks of data on behalf of the user.

A keychain is a locked, encrypted container used in Keychain Access to store account names and passwords for apps, servers, AirPort base stations, and websites. You can also use keychains to store confidential information such as credit card numbers or personal identification numbers (PINs) for bank accounts.

키체인은 키체인엑세스에서 앱,서버, AirPort 기지국 및 웹 사이트의 계정 이름과 암호를 저장하기 위해 사용되는 잠겨있고, 암호화된 컨테이너이다. 또한 주요 키체인을 사용하여 신용카드 번호 또는 은행 계좌의 개인 식별번호(PIN)와 같은 기밀 정보를 저장할 수 있다.

Basic Keychain Concepts

  • Keychain: 민감한 정보를 안전하게 저장할 수 있는 암호화된 데이터 저장소
  • Keychain Item: 키체인의 레지스트리
  • Item Class: 아이디와 비밀번호, 인증서와 같은 증명서를 저장할 수 있게 해 주는 클래스

Using the iOS Keychain in Swift

Keyed Archiver, User Defaults, CoreData와 다른 점은 무엇일까?

Keyed Archiver

저장할 데이터가 NSConfig 프로토콜을 채택해야하고, 데이터 저장시에 키/이름으로 인코딩하고 꺼내올 때, 디코딩을 이용한다.

disk와 직접 소통할 수 있는 능력을 제공함

구체적으로, NSCoding 프로토콜을 serialize함

NSCoding은 다음의 두 가지 메서드를 가짐

  1. encode(with aCoder: NSCoder)
  2. init?(coder aDecoder: NSCoder)

사용방법이 굉장히 간단함

NSKeyedArchiver를 이용해서 정보를 저장하고 싶으면,
NSKeyedArchiver.archiveRootObject를 호출하면 됨

NSKeyedArchiver는 Core Data보다 구현하기가 훨씬 간단함

User Defaults

다양한 데이터 타입을 저장할 수 있는 저장소를 제공하는 클래스

앱이 시작하고 기기가 재시작되는 사이의 데이터를 저장하는 용도로 사용된다. UserDefaults는 bool, float, double과 같은 기본 타입뿐 아니라 배열, 딕셔너리와 같은 좀 더 복잡한 타입을 저장할 수 있다. UserDefaults는 정해진 구조가 없고 key와 value값으로만 구성되어있기 때문에 core data보다 더 빠르다고 알려져있다.

User Defaults은 CoreData와는 다르게 정해진 구조(entity)가 없는 데이터를 저장하는데 유용하다.

그에 반해 비밀번호와 같은 개인정보를 저장하기에는 적합하지 않습니다.

같은 키값으로 다른 데이터를 중복저장하면 이전의 데이터는 새로운 데이터로 교체됩니다.

CoreData

복잡한 쿼리를 짤 필요가 없다.

각 각의 데이터 개체가 특정한 속성을 가지도록(테이블형식) 설계되어 있다. 각 테이블 간에 관계를 가질수도 아닐수도 있다.

자동 마이그레이션 기능. 코어 데이터 모델을 생성하면 SQLite 데이터 베이스가 생성된다. 데이터 모델을 변경하거나 수정할 경우 수정된 데이터 모델은 기존의 데이터 모델에 호환 되도록 마이그레이션 기능을 애플이 지원한다.

.xcdatamodel 파일을 통하여 CoreData를 생성하고 해당 CoreData를 앱에 반영시킬 수 있는 .swift파일을 작성하여 적용시킨다.

Core Data vs. NSKeyedArchiver vs. User Defaults

iOS의 키체인과 macOS의 키체인의 차이는?

iOS - 단일 키체인(a Single Keychain) 생성 및 관리

MacOS - 시스템에서 여러개의 키체인을 사용할 수 있다. (an arbitrary number of keychains.)

You can use the Keychain Access app on your Mac to view and manage your keychains.

iCloud - iCloud Keychain을 이용하면 비밀번호와 다른 개인 정보들을 모든 디바이스에 걸쳐 업데이트된 상태로 보관할 수 있다.

When you use iCloud Keychain, you can keep your passwords and other secure information updated across your devices

  • arbitrary: 임의의

Manage passwords using keychains on Mac

키체인 서비스를 사용하기 위해 k- 접두어를 사용하는 여러 타입과 값을 사용합니다

  • k- 접두어의 비밀은?

k-접두어란 상수의 의미로 표현한것.

"k" 접두어는 헝가리언 네이밍에 따라 사용됐다. Constants의 'c'는 이미 헝가리안에서 'char'의 'c'로 예약이 되어있어서, 동일한 발음 기호인 'k' 를 사용했다

[iOS] Constants 정의 시, 'k' prefix 사용은 적절한가

  • 어떤 프레임워크의 값일까?

Core Foundation → Core Foundation에 포함된 프로퍼티로 CFString 타입이다.

→ Low-Level functions으로 원시 데이터 타입에 접근하여 Foundation 프레임워크와 원활하게 연동 시켜줌.

→ Core Foundation은 iOS계층에서 Core Services이고 Foundation은 Cocoa Touch계층

* Low-Level functions : 메모리상의 데이터를 직접적으로 다루는 함수

* Core Services : 주요 운영체제 서비스에 엑세스하고 관리합니다.(시작 및 ID서비스와 같은..)

Apple Developer Documentation

  • Cocoa : 애플 환경에서 어플리케이션 제작을 위한 도구의 모음.

* Cocoa Touch계층 : Cocoa Touch에서는 Foundation은 같지만 UIkit를 사용함.

Apple Developer Documentation

iOS - Cocoa, Cocoa Touch(Foundation, UIKit) 개념 알아보기

KeyChain

  • Core Foundation 프레임워크와 Foundation 프레임워크와의 차이는?

iOS의 4가지 계층

Core OS / Core Services

Media Layer / Cocoa Touch

  • Bonjour : 서비스 디스커버리 프로토콜인 제로콘프(Zeroconf)를 구현해주는 소프트웨어

  • 제로콘프(Zeroconf) : (Zero configuration networking)은 사람손에 의한 조작없이, 또한 특별한 설정서버를 사용하지 않고 이용가능한 인터넷프로토콜(IP)네트워크를 자동적으로 작성하는 일종의 기법.

  • OPENSTEP : 객체지향형 API 표준

  • Carbon :

Carbon Design System - Wikipedia

Foundation과 Core Foundation 프레임웍

  • 키체인은 언제 사용하면 좋을까?

키체인은 패스워드 그리고 보안키와 같은 개인정보를 저장하는 용도로 사용하는 것이 적합합니다.. 키체인의 서비스 API를 통해 키체인의 데이터를 추가, 수정, 제거할 수 있습니다.

The keychain is the best place to store small secrets, like passwords and cryptographic keys. You use the functions of the keychain services API to add, retrieve, delete, or modify keychain items.

The keychain services API helps you solve this problem by giving your app a mechanism to store small bits of user data in an encrypted database called a keychain. When you securely remember the password for them, you free the user to choose a complicated one.

Apple Developer Documentation

Apple Developer Documentation

Security and Your Apps - WWDC 2015 - Videos - Apple Developer

Protecting Secrets with the Keychain - WWDC 2013 - Videos - Apple Developer

profile
iOS Developer

0개의 댓글