{"action":"created","comment":{"url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments/51410788","id":51410788,"diff_hunk":"@@ -413,9 +414,104 @@ static TEE_Result tee_rpmb_invoke(struct tee_rpmb_mem *mem)\n \treturn thread_rpc_cmd(TEE_RPC_RPMB_CMD, 2, params);\n }\n \n+#ifdef CFG_ENC_FS\n+static bool is_null_or_zero(const uint8_t *fek)\n+{\n+\tint i;\n+\n+\tif (!fek)\n+\t\treturn true;\n+\tfor (i = 0; i < TEE_FS_KM_FEK_SIZE; i++)\n+\t\tif (fek[i])\n+\t\t\treturn false;\n+\treturn true;\n+}\n+\n+static TEE_Result crypt_block(uint8_t *out, const uint8_t *in,\n+\t\t\t      uint16_t blk_idx, const uint8_t *fek,\n+\t\t\t      const uint8_t *nonce, TEE_OperationMode mode)\n+{\n+\tif (is_null_or_zero(fek)) {\n+\t\t/*\n+\t\t * Unencrypted block, either because it does not belong to the\n+\t\t * data area of a file (!fek), or because the file was created\n+\t\t * with no encryption (e.g., by OP-TEE with CFG_ENC_FS=n).\n+\t\t */","path":"core/arch/arm/tee/tee_rpmb.c","position":43,"original_position":43,"commit_id":"82c724079db0434f8ef297a48dd106401005e963","original_commit_id":"82c724079db0434f8ef297a48dd106401005e963","user":{"login":"jforissier","id":8288195,"avatar_url":"https://avatars.githubusercontent.com/u/8288195?v=3","gravatar_id":"","url":"https://api.github.com/users/jforissier","html_url":"https://github.com/jforissier","followers_url":"https://api.github.com/users/jforissier/followers","following_url":"https://api.github.com/users/jforissier/following{/other_user}","gists_url":"https://api.github.com/users/jforissier/gists{/gist_id}","starred_url":"https://api.github.com/users/jforissier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jforissier/subscriptions","organizations_url":"https://api.github.com/users/jforissier/orgs","repos_url":"https://api.github.com/users/jforissier/repos","events_url":"https://api.github.com/users/jforissier/events{/privacy}","received_events_url":"https://api.github.com/users/jforissier/received_events","type":"User","site_admin":false},"body":"What do you mean by \"safe\"? I don't see any issue with this. Of course we could also just refuse to read a file that is not encrypted, but why?","created_at":"2016-02-01T12:10:52Z","updated_at":"2016-02-01T12:10:52Z","html_url":"https://github.com/OP-TEE/optee_os/pull/626#discussion_r51410788","pull_request_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626","_links":{"self":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments/51410788"},"html":{"href":"https://github.com/OP-TEE/optee_os/pull/626#discussion_r51410788"},"pull_request":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626"}}},"pull_request":{"url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626","id":56909561,"html_url":"https://github.com/OP-TEE/optee_os/pull/626","diff_url":"https://github.com/OP-TEE/optee_os/pull/626.diff","patch_url":"https://github.com/OP-TEE/optee_os/pull/626.patch","issue_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/626","number":626,"state":"open","locked":false,"title":"RPMB encryption","user":{"login":"jforissier","id":8288195,"avatar_url":"https://avatars.githubusercontent.com/u/8288195?v=3","gravatar_id":"","url":"https://api.github.com/users/jforissier","html_url":"https://github.com/jforissier","followers_url":"https://api.github.com/users/jforissier/followers","following_url":"https://api.github.com/users/jforissier/following{/other_user}","gists_url":"https://api.github.com/users/jforissier/gists{/gist_id}","starred_url":"https://api.github.com/users/jforissier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jforissier/subscriptions","organizations_url":"https://api.github.com/users/jforissier/orgs","repos_url":"https://api.github.com/users/jforissier/repos","events_url":"https://api.github.com/users/jforissier/events{/privacy}","received_events_url":"https://api.github.com/users/jforissier/received_events","type":"User","site_admin":false},"body":"~~This PR is to review the RPMB file encryption patch: https://github.com/OP-TEE/optee_os/commit/0a09e0f8eef19c7c1b5b5d0a6b2260b6752091b6. Please review only this patch ;  the other ones are just prerequisites and come from PR https://github.com/OP-TEE/optee_os/pull/616.~~\r\n","created_at":"2016-01-22T16:30:12Z","updated_at":"2016-02-01T12:10:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e069aab386cfce1dde6d42835c0a295fa0acfed2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626/commits","review_comments_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626/comments","review_comment_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/626/comments","statuses_url":"https://api.github.com/repos/OP-TEE/optee_os/statuses/82c724079db0434f8ef297a48dd106401005e963","head":{"label":"jforissier:rpmb-encryption","ref":"rpmb-encryption","sha":"82c724079db0434f8ef297a48dd106401005e963","user":{"login":"jforissier","id":8288195,"avatar_url":"https://avatars.githubusercontent.com/u/8288195?v=3","gravatar_id":"","url":"https://api.github.com/users/jforissier","html_url":"https://github.com/jforissier","followers_url":"https://api.github.com/users/jforissier/followers","following_url":"https://api.github.com/users/jforissier/following{/other_user}","gists_url":"https://api.github.com/users/jforissier/gists{/gist_id}","starred_url":"https://api.github.com/users/jforissier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jforissier/subscriptions","organizations_url":"https://api.github.com/users/jforissier/orgs","repos_url":"https://api.github.com/users/jforissier/repos","events_url":"https://api.github.com/users/jforissier/events{/privacy}","received_events_url":"https://api.github.com/users/jforissier/received_events","type":"User","site_admin":false},"repo":{"id":22514248,"name":"optee_os","full_name":"jforissier/optee_os","owner":{"login":"jforissier","id":8288195,"avatar_url":"https://avatars.githubusercontent.com/u/8288195?v=3","gravatar_id":"","url":"https://api.github.com/users/jforissier","html_url":"https://github.com/jforissier","followers_url":"https://api.github.com/users/jforissier/followers","following_url":"https://api.github.com/users/jforissier/following{/other_user}","gists_url":"https://api.github.com/users/jforissier/gists{/gist_id}","starred_url":"https://api.github.com/users/jforissier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jforissier/subscriptions","organizations_url":"https://api.github.com/users/jforissier/orgs","repos_url":"https://api.github.com/users/jforissier/repos","events_url":"https://api.github.com/users/jforissier/events{/privacy}","received_events_url":"https://api.github.com/users/jforissier/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jforissier/optee_os","description":"Trusted side of the TEE","fork":true,"url":"https://api.github.com/repos/jforissier/optee_os","forks_url":"https://api.github.com/repos/jforissier/optee_os/forks","keys_url":"https://api.github.com/repos/jforissier/optee_os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jforissier/optee_os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jforissier/optee_os/teams","hooks_url":"https://api.github.com/repos/jforissier/optee_os/hooks","issue_events_url":"https://api.github.com/repos/jforissier/optee_os/issues/events{/number}","events_url":"https://api.github.com/repos/jforissier/optee_os/events","assignees_url":"https://api.github.com/repos/jforissier/optee_os/assignees{/user}","branches_url":"https://api.github.com/repos/jforissier/optee_os/branches{/branch}","tags_url":"https://api.github.com/repos/jforissier/optee_os/tags","blobs_url":"https://api.github.com/repos/jforissier/optee_os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jforissier/optee_os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jforissier/optee_os/git/refs{/sha}","trees_url":"https://api.github.com/repos/jforissier/optee_os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jforissier/optee_os/statuses/{sha}","languages_url":"https://api.github.com/repos/jforissier/optee_os/languages","stargazers_url":"https://api.github.com/repos/jforissier/optee_os/stargazers","contributors_url":"https://api.github.com/repos/jforissier/optee_os/contributors","subscribers_url":"https://api.github.com/repos/jforissier/optee_os/subscribers","subscription_url":"https://api.github.com/repos/jforissier/optee_os/subscription","commits_url":"https://api.github.com/repos/jforissier/optee_os/commits{/sha}","git_commits_url":"https://api.github.com/repos/jforissier/optee_os/git/commits{/sha}","comments_url":"https://api.github.com/repos/jforissier/optee_os/comments{/number}","issue_comment_url":"https://api.github.com/repos/jforissier/optee_os/issues/comments{/number}","contents_url":"https://api.github.com/repos/jforissier/optee_os/contents/{+path}","compare_url":"https://api.github.com/repos/jforissier/optee_os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jforissier/optee_os/merges","archive_url":"https://api.github.com/repos/jforissier/optee_os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jforissier/optee_os/downloads","issues_url":"https://api.github.com/repos/jforissier/optee_os/issues{/number}","pulls_url":"https://api.github.com/repos/jforissier/optee_os/pulls{/number}","milestones_url":"https://api.github.com/repos/jforissier/optee_os/milestones{/number}","notifications_url":"https://api.github.com/repos/jforissier/optee_os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jforissier/optee_os/labels{/name}","releases_url":"https://api.github.com/repos/jforissier/optee_os/releases{/id}","deployments_url":"https://api.github.com/repos/jforissier/optee_os/deployments","created_at":"2014-08-01T14:48:31Z","updated_at":"2015-04-27T10:55:52Z","pushed_at":"2016-01-29T13:06:17Z","git_url":"git://github.com/jforissier/optee_os.git","ssh_url":"git@github.com:jforissier/optee_os.git","clone_url":"https://github.com/jforissier/optee_os.git","svn_url":"https://github.com/jforissier/optee_os","homepage":null,"size":7159,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"OP-TEE:master","ref":"master","sha":"a8a78b857b907f73497d48bab6304cf29aba3636","user":{"login":"OP-TEE","id":7488961,"avatar_url":"https://avatars.githubusercontent.com/u/7488961?v=3","gravatar_id":"","url":"https://api.github.com/users/OP-TEE","html_url":"https://github.com/OP-TEE","followers_url":"https://api.github.com/users/OP-TEE/followers","following_url":"https://api.github.com/users/OP-TEE/following{/other_user}","gists_url":"https://api.github.com/users/OP-TEE/gists{/gist_id}","starred_url":"https://api.github.com/users/OP-TEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OP-TEE/subscriptions","organizations_url":"https://api.github.com/users/OP-TEE/orgs","repos_url":"https://api.github.com/users/OP-TEE/repos","events_url":"https://api.github.com/users/OP-TEE/events{/privacy}","received_events_url":"https://api.github.com/users/OP-TEE/received_events","type":"Organization","site_admin":false},"repo":{"id":20193261,"name":"optee_os","full_name":"OP-TEE/optee_os","owner":{"login":"OP-TEE","id":7488961,"avatar_url":"https://avatars.githubusercontent.com/u/7488961?v=3","gravatar_id":"","url":"https://api.github.com/users/OP-TEE","html_url":"https://github.com/OP-TEE","followers_url":"https://api.github.com/users/OP-TEE/followers","following_url":"https://api.github.com/users/OP-TEE/following{/other_user}","gists_url":"https://api.github.com/users/OP-TEE/gists{/gist_id}","starred_url":"https://api.github.com/users/OP-TEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OP-TEE/subscriptions","organizations_url":"https://api.github.com/users/OP-TEE/orgs","repos_url":"https://api.github.com/users/OP-TEE/repos","events_url":"https://api.github.com/users/OP-TEE/events{/privacy}","received_events_url":"https://api.github.com/users/OP-TEE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OP-TEE/optee_os","description":"Trusted side of the TEE","fork":false,"url":"https://api.github.com/repos/OP-TEE/optee_os","forks_url":"https://api.github.com/repos/OP-TEE/optee_os/forks","keys_url":"https://api.github.com/repos/OP-TEE/optee_os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OP-TEE/optee_os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OP-TEE/optee_os/teams","hooks_url":"https://api.github.com/repos/OP-TEE/optee_os/hooks","issue_events_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/events{/number}","events_url":"https://api.github.com/repos/OP-TEE/optee_os/events","assignees_url":"https://api.github.com/repos/OP-TEE/optee_os/assignees{/user}","branches_url":"https://api.github.com/repos/OP-TEE/optee_os/branches{/branch}","tags_url":"https://api.github.com/repos/OP-TEE/optee_os/tags","blobs_url":"https://api.github.com/repos/OP-TEE/optee_os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OP-TEE/optee_os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OP-TEE/optee_os/git/refs{/sha}","trees_url":"https://api.github.com/repos/OP-TEE/optee_os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OP-TEE/optee_os/statuses/{sha}","languages_url":"https://api.github.com/repos/OP-TEE/optee_os/languages","stargazers_url":"https://api.github.com/repos/OP-TEE/optee_os/stargazers","contributors_url":"https://api.github.com/repos/OP-TEE/optee_os/contributors","subscribers_url":"https://api.github.com/repos/OP-TEE/optee_os/subscribers","subscription_url":"https://api.github.com/repos/OP-TEE/optee_os/subscription","commits_url":"https://api.github.com/repos/OP-TEE/optee_os/commits{/sha}","git_commits_url":"https://api.github.com/repos/OP-TEE/optee_os/git/commits{/sha}","comments_url":"https://api.github.com/repos/OP-TEE/optee_os/comments{/number}","issue_comment_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/comments{/number}","contents_url":"https://api.github.com/repos/OP-TEE/optee_os/contents/{+path}","compare_url":"https://api.github.com/repos/OP-TEE/optee_os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OP-TEE/optee_os/merges","archive_url":"https://api.github.com/repos/OP-TEE/optee_os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OP-TEE/optee_os/downloads","issues_url":"https://api.github.com/repos/OP-TEE/optee_os/issues{/number}","pulls_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls{/number}","milestones_url":"https://api.github.com/repos/OP-TEE/optee_os/milestones{/number}","notifications_url":"https://api.github.com/repos/OP-TEE/optee_os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OP-TEE/optee_os/labels{/name}","releases_url":"https://api.github.com/repos/OP-TEE/optee_os/releases{/id}","deployments_url":"https://api.github.com/repos/OP-TEE/optee_os/deployments","created_at":"2014-05-26T17:18:57Z","updated_at":"2016-01-26T19:32:07Z","pushed_at":"2016-02-01T09:53:30Z","git_url":"git://github.com/OP-TEE/optee_os.git","ssh_url":"git@github.com:OP-TEE/optee_os.git","clone_url":"https://github.com/OP-TEE/optee_os.git","svn_url":"https://github.com/OP-TEE/optee_os","homepage":null,"size":8342,"stargazers_count":87,"watchers_count":87,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":93,"mirror_url":null,"open_issues_count":19,"forks":93,"open_issues":19,"watchers":87,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626"},"html":{"href":"https://github.com/OP-TEE/optee_os/pull/626"},"issue":{"href":"https://api.github.com/repos/OP-TEE/optee_os/issues/626"},"comments":{"href":"https://api.github.com/repos/OP-TEE/optee_os/issues/626/comments"},"review_comments":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626/comments"},"review_comment":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/626/commits"},"statuses":{"href":"https://api.github.com/repos/OP-TEE/optee_os/statuses/82c724079db0434f8ef297a48dd106401005e963"}}}}