blob: a84026b8c0dfe663bcb0acd7edae5f3dd98a5790 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using System;
using System.IO;
namespace Org.BouncyCastle.Crypto.Tls
{
public class NewSessionTicket
{
protected readonly long mTicketLifetimeHint;
protected readonly byte[] mTicket;
public NewSessionTicket(long ticketLifetimeHint, byte[] ticket)
{
this.mTicketLifetimeHint = ticketLifetimeHint;
this.mTicket = ticket;
}
public virtual long TicketLifetimeHint
{
get { return mTicketLifetimeHint; }
}
public virtual byte[] Ticket
{
get { return mTicket; }
}
/**
* Encode this {@link NewSessionTicket} to a {@link Stream}.
*
* @param output the {@link Stream} to encode to.
* @throws IOException
*/
public virtual void Encode(Stream output)
{
TlsUtilities.WriteUint32(mTicketLifetimeHint, output);
TlsUtilities.WriteOpaque16(mTicket, output);
}
/**
* Parse a {@link NewSessionTicket} from a {@link Stream}.
*
* @param input the {@link Stream} to parse from.
* @return a {@link NewSessionTicket} object.
* @throws IOException
*/
public static NewSessionTicket Parse(Stream input)
{
long ticketLifetimeHint = TlsUtilities.ReadUint32(input);
byte[] ticket = TlsUtilities.ReadOpaque16(input);
return new NewSessionTicket(ticketLifetimeHint, ticket);
}
}
}
|