Skip to content

Commit 1f8a19a

Browse files
committed
Rename Identity::pubkey to credential for clarity
Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
1 parent 79fcda3 commit 1f8a19a

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

examples/agent-socket-info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Session for AgentSocketInfo {
2727
async fn request_identities(&mut self) -> Result<Vec<Identity>, AgentError> {
2828
Ok(vec![Identity {
2929
// this is just a dummy key, the comment is important
30-
pubkey: KeyData::Ed25519(ssh_key::public::Ed25519PublicKey([0; 32])).into(),
30+
credential: KeyData::Ed25519(ssh_key::public::Ed25519PublicKey([0; 32])).into(),
3131
comment: self.comment.clone(),
3232
}])
3333
}

examples/key-storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Session for KeyStorage {
122122
let mut identities = vec![];
123123
for identity in self.identities.lock().unwrap().iter() {
124124
identities.push(message::Identity {
125-
pubkey: identity.pubkey.key_data().clone().into(),
125+
credential: identity.pubkey.key_data().clone().into(),
126126
comment: identity.comment.clone(),
127127
})
128128
}

examples/random-key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Session for RandomKey {
8888
async fn request_identities(&mut self) -> Result<Vec<Identity>, AgentError> {
8989
let identity = self.private_key.lock().unwrap();
9090
Ok(vec![Identity {
91-
pubkey: PublicCredential::Key(PublicKey::from(identity.deref()).into()),
91+
credential: PublicCredential::Key(PublicKey::from(identity.deref()).into()),
9292
comment: identity.comment().into(),
9393
}])
9494
}

src/proto/message/identity.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::proto::{Error, Result};
1313
#[derive(Clone, PartialEq, Debug)]
1414
pub struct Identity {
1515
/// A standard public-key encoding of an underlying key.
16-
pub pubkey: PublicCredential,
16+
pub credential: PublicCredential,
1717

1818
/// A human-readable comment
1919
pub comment: String,
@@ -36,24 +36,27 @@ impl Decode for Identity {
3636
type Error = Error;
3737

3838
fn decode(reader: &mut impl Reader) -> Result<Self> {
39-
let pubkey = reader.read_prefixed(PublicCredential::decode)?;
39+
let credential = reader.read_prefixed(PublicCredential::decode)?;
4040
let comment = String::decode(reader)?;
4141

42-
Ok(Self { pubkey, comment })
42+
Ok(Self {
43+
credential,
44+
comment,
45+
})
4346
}
4447
}
4548

4649
impl Encode for Identity {
4750
fn encoded_len(&self) -> ssh_encoding::Result<usize> {
4851
[
49-
self.pubkey.encoded_len_prefixed()?,
52+
self.credential.encoded_len_prefixed()?,
5053
self.comment.encoded_len()?,
5154
]
5255
.checked_sum()
5356
}
5457

5558
fn encode(&self, writer: &mut impl Writer) -> ssh_encoding::Result<()> {
56-
self.pubkey.encode_prefixed(writer)?;
59+
self.credential.encode_prefixed(writer)?;
5760
self.comment.encode(writer)?;
5861

5962
Ok(())

src/proto/message/request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ mod tests {
193193
panic!("expected IdentitiesAnswer");
194194
};
195195
assert_eq!(resp.len(), 4);
196-
let PublicCredential::Cert(cert) = &resp[3].pubkey else {
196+
let PublicCredential::Cert(cert) = &resp[3].credential else {
197197
panic!("expected certificate");
198198
};
199199
assert_eq!(cert.algorithm(), Algorithm::Rsa { hash: None });
@@ -209,7 +209,7 @@ mod tests {
209209
panic!("expected IdentitiesAnswer");
210210
};
211211
assert_eq!(resp.len(), 1);
212-
let PublicCredential::Key(key) = &resp[0].pubkey else {
212+
let PublicCredential::Key(key) = &resp[0].credential else {
213213
panic!("expected key");
214214
};
215215
assert_eq!(key.algorithm(), Algorithm::Rsa { hash: None });

tests/roundtrip/expected/resp_parse_identities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::fixtures;
55

66
pub fn expected() -> Response {
77
Response::IdentitiesAnswer(vec![Identity {
8-
pubkey: KeyData::Ecdsa(fixtures::demo_key().into()).into(),
8+
credential: KeyData::Ecdsa(fixtures::demo_key().into()).into(),
99
comment: "baloo@angela".to_string(),
1010
}])
1111
}

0 commit comments

Comments
 (0)