{"id":20841599,"url":"https://github.com/iotexproject/ucam-pe-lib","last_synced_at":"2026-04-20T22:04:20.112Z","repository":{"id":97187872,"uuid":"299128822","full_name":"iotexproject/ucam-pe-lib","owner":"iotexproject","description":"This is UCam Privacy Enhancement (PE) library that implements security and privacy related features for Ucam (https://ucam.iotex.io)","archived":false,"fork":false,"pushed_at":"2020-09-28T05:43:06.000Z","size":728,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-12-28T11:06:29.547Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iotexproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-09-27T22:14:51.000Z","updated_at":"2022-06-24T12:41:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2e528a3-f1f1-4ab0-bbd3-8e0b88e5996e","html_url":"https://github.com/iotexproject/ucam-pe-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iotexproject/ucam-pe-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotexproject%2Fucam-pe-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotexproject%2Fucam-pe-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotexproject%2Fucam-pe-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotexproject%2Fucam-pe-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iotexproject","download_url":"https://codeload.github.com/iotexproject/ucam-pe-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotexproject%2Fucam-pe-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32067637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T21:26:33.338Z","status":"ssl_error","status_checked_at":"2026-04-20T21:26:22.081Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T01:20:54.532Z","updated_at":"2026-04-20T22:04:20.106Z","avatar_url":"https://github.com/iotexproject.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UCam Privacy Enhancement Lib\n\nThis is UCam Privacy Enhancement (PE) library that is invoked by the main firmware (which is unfortunately close source) to :\n* Encrypt snapshot provided by the main firmware.\n* Encrypt video stream frame by frame.\n* Upload encrypted video frame file.\n* Upload encrypted snapshot to AWS S3 and Filecoin (WIP).\n* Handle OTA update via IPFS\n\n## Layout\nThis lib depends on `libcurl` and `libmbedtls`, primarily contains `ioecr` and `emulator`, where the former implements the privacy-enhancement features while the latter is for emulation and testing purposes. For `ioecr`, the most important files are:\n```\n |-- libioecr.h: API interface\n |-- libioecr.a: static library of the API implementation\n```\n\n## How to Use\n### 1. Register callback\n\nThe SDK needs couple of callback from firmware to make it work properly. So first firmware needs to make 2 calls\n```\n  int ioecr_initialize_recorder(\n    cb_get_credential get_credential,\n    cb_release_credential release_credential);\n```\n\nCorrespondingly, they can be release with `void ioecr_release_recorder();`\n\nthis will register these callbacks for use by video upload component `int ioecr_initialize_encryptor();`\n\nthis loads the key into the encryption component. The corresponding release function is `void ioecr_release_encryptor();``\n\n### 2. Check encryption key\n\nTo check if a key matches current key, firmware needs to call `int ioecr_check_encryption_key(const uint8_t* hash, int length, uint32_t *nonce);`\n\nhash is 20-byte buffer containing the hmac-sha1() of current key, length must be 20.\n\n### 3. Set encryption key\nTo set encryption key, firmware needs to call\n\n`int ioecr_set_encryption_key(uint32_t nonce, const uint8_t* key, int length, const uint8_t *curr_key_hash, int hash_length);``\n\nkey is 16-byte buffer containing new key, length must be 16, `curr_key_hash` is same as input to `ioecr_check_encryption_key`, hash_length must be 20.\n\nUpon success, the provided key is written into the file \"/rom/key\" on the camera file system.\n\nIf `ioecr_set_encryption_key()` is not called, or is called with key == NULL, then encryption is disabled.\nTo enable encryption, `ioecr_set_encryption_key()` must be called with a valid 16-byte key.\n\n### 4. Encrypt a frame\n\nTo encrypt a frame, firmware needs to call\n`int ioecr_encrypt(uint8_t *buffer, uint32_t buffer_size, uint8_t *nonce_counter, uint8_t *key_hash);`\n\nreturn value will be 0 if encryption is disabled, \u003e 0 is the encryption algorithm ID (currently 1), firmware needs to write this ID (or 0 meaning disabled) into frame header. A value \u003c 0 indicates error code from encryption library.\n\n`nonce_counter` is 16-byte buffer, and contains the nonce and counter needed to decrypt the frame.\nkey_hash is 4-byte buffer, and contains the first 4-bytes of hmac-sha1() of current encryption key\n\n### 5. Record a video clip (and/or snapshot)\n\nTo respond to an alarm event, firmware needs to call\n`int ioecr_start_recording(pthread_t* pthreadid);``\n\nIf user has video privilege, this will upload to S3 storage one or more files. Each video file contains multiple video frames, where each video frame consists of a `st_frame_header` (28-bytes), followed by the actual frame data. The library keeps calling firmware's callback `cb_get_frame(\u0026frameinfo)`, fill the header and copy actual frame data according to `frameinfo`, until all frames up to the requested time have been processed and uploaded.\n\nIf user has snapshot privilege, this will upload to S3 storage 'snapshot_count' snapshot files. Each file contains a size_t follow with the frame data.\n\n# Contribute\n\nWant to contribute to the this firmware project? Follow [this link](CONTRIBUTIONS.md) to find out how.\n\n# License\nUnless stated elsewhere, file headers or otherwise, all files herein are licensed under an LGPLv3 license. For more information, please read the LICENSE file.\n\nThis license allows businesses to confidently build firmware and make devices without risk to their intellectual property, while at the same time helping the community benefit from non-proprietary contributions to the shared System Firmware.\n\n# Connect\n\nHaving problems or have awesome suggestions? Connect with us [here](support@iotex.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiotexproject%2Fucam-pe-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiotexproject%2Fucam-pe-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiotexproject%2Fucam-pe-lib/lists"}