| // Copyright 2021 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.ssh; |
| |
| using zx; |
| |
| /// Maximum length of a single SSH key. See sshd(8). |
| const MAX_SSH_KEY_LENGTH uint32 = 8192; |
| |
| type SshAuthorizedKeyEntry = struct { |
| /// The entry in authorized_keys. |
| key string:MAX_SSH_KEY_LENGTH; |
| }; |
| |
| /// Protocol for managing SSH keys on a device. |
| @discoverable |
| protocol AuthorizedKeys { |
| /// Add a key to the device's authorized key list. |
| AddKey(struct { |
| key SshAuthorizedKeyEntry; |
| }) -> (struct {}) error zx.status; |
| |
| /// Watch for keys by sending events to the given KeyWatcher. |
| WatchKeys(resource struct { |
| watcher server_end:KeyWatcher; |
| }); |
| |
| /// Remove the given key. |key| should be a value returned by |KeyIterator|. |
| RemoveKey(struct { |
| key SshAuthorizedKeyEntry; |
| }) -> (struct {}) error zx.status; |
| }; |
| |
| type KeyEventType = strict enum { |
| /// This key already existed when WatchKeys was called. |
| EXISTING = 1; |
| /// This key was added after WatchKeys was called. |
| ADDED = 2; |
| /// This key was removed after WatchKeys was called. |
| REMOVED = 3; |
| /// This is the end of the EXISTING keys. |
| FINISHED_EXISTING = 4; |
| }; |
| |
| /// Event for an SSH key being added or removed. |
| type KeyEvent = struct { |
| /// What is happening to this key? |
| event KeyEventType; |
| /// The key. Present for all KeyEventType except FINISHED_EXISTING. |
| key box<SshAuthorizedKeyEntry>; |
| }; |
| |
| /// Used to send updates about the authorized key list from server to client. |
| protocol KeyWatcher { |
| /// Blocks until the next event is ready. |
| Next() -> (struct { |
| event KeyEvent; |
| }); |
| }; |