C# 클래스 Brunet.Security.PeerSec.PeerSecOverlord

This is the brains of the operation. User code can ask for a Secure Sender for a given sender, this will return one and begin the process of securing the sender. Sending over a sender is only secure if it is done throug the secure sender. On the other side, the user should ensure that the packet was sent via a secure sender at some point in the stack.
상속: SecurityOverlord, IReplyHandler
파일 보기 프로젝트 열기: pstjuste/brunet 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
CookieLength int
EmptyCookie MemBlock
SecureControl PType
SecureData PType
Security PType
Version int

보호된 프로퍼티들

프로퍼티 타입 설명
_cookie byte[]
_last_heartbeat System.DateTime
_private_key_lock object
_rand System.Random
_rrman ReqrepManager
_spi Dictionary>

공개 메소드들

메소드 설명
CalculateCookie ( object o ) : MemBlock

We take in an object, take its hash code, concatenate it to our cookie, then sha hash the resulting value, creating the remote cookie.

CheckForSecurityAssociation ( ISender sender ) : Brunet.SecurityAssociation
CreateSecurityAssociation ( ISender Sender, int SPI ) : PeerSecAssociation

This (idempotently) returns a new SecurityAssociation for the specified sender using the specified SPI and starts it if requested to.

CreateSecurityAssociation ( ISender Sender ) : Brunet.SecurityAssociation

This (idempotently) returns a new SecurityAssociation for the specified sender using the default SPI and starts it if requested to.

HandleData ( MemBlock data, ISender return_path, object state ) : void

All messages for the SecurityOverlord come through this loop. It demuxes between Security, SecureData, and SecureControl packets, while the remaining packets are left to the default handler.

HandleError ( ReqrepManager man, int message_number, ReqrepManager err, ISender returnpath, object state ) : void

If the request really failed, we'll have to close the SA.

HandleReply ( ReqrepManager man, ReqrepManager rt, int mid, PType prot, MemBlock payload, ISender returnpath, ReqrepManager statistics, object state ) : bool

This better be a SecureControl message!

PeerSecOverlord ( RSACryptoServiceProvider rsa, Brunet.CertificateHandler ch, ReqrepManager rrman ) : Brunet

보호된 메소드들

메소드 설명
CreateSecurityAssociation ( ISender Sender, int SPI, bool start ) : PeerSecAssociation

This (idempotently) returns a new SecurityAssociation for the specified sender using the specified SA.

HandleControl ( MemBlock b, ISender return_path ) : void

This is the control state machine. There are three paths in the state machine, iniator, receiver, and bidirectional. The bidirectional case occurs when two remote ISenders that are matched together initiate a handshake at the same time, otherwise the initiator /receiver pattern is followed. The high level overview for the states are: 1a) Send a Cookie 1b) Receive a Cookie which responds with a CookieResponse 2a) Receive a CookieResponse that contains a list of CAs, if you have a Certificate that supports one of the CAs send it along with a DHE and a list of your supported CAs in a DHEWithCertificateAndCAs. 2b) Receive a DHEWithCertificateAndCAs, verify the certificate and attempt to find a matching Certificate for the list of CAs, if you find one, finish the DHE handshake and send the certificate via a DHEWithCertificate 3a) Receive a DHEWithCertificate, verify the certificate and DHE and send a Confirm that you are ready to Verify the stack and start the system. 3b) Receive a Confirm, verify the entire stack and send a Confirm 4a)Receive a Confirm, verify the entire stack and all set to go

HandleControlConfirm ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void

3b) Receive a Confirm, verify the entire stack and send a Confirm 4a)Receive a Confirm, verify the entire stack and all set to go

HandleControlCookie ( PeerSecAssociation sa, MemBlock calc_cookie, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void

1b) Receive a Cookie which responds with a CookieResponse

HandleControlCookieResponse ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void

2a) Receive a CookieResponse that contains a list of CAs, if you have a Certificate that supports one of the CAs send it along with a DHE and a list of your supported CAs in a DHEWithCertificateAndCAs.

HandleControlDHEWithCertificate ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void

3a) Receive a DHEWithCertificate, verify the certificate and DHE and send a Confirm that you are ready to Verify the stack and start the system.

HandleControlDHEWithCertificateAndCAs ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void

2b) Receive a DHEWithCertificateAndCAs, verify the certificate and attempt to find a matching Certificate for the list of CAs, if you find one, finish the DHE handshake and send the certificate via a DHEWithCertificate

HandleControlNoSuchSA ( PeerSecAssociation sa ) : void

1a) Send a Cookie

HandleData ( MemBlock b, ISender return_path ) : void

This is SecureData that needs to get to an SA.

NoSuchSA ( int spi, ISender remote_sender ) : void

After a restart of the Security system, one guy may think we still have an association and there will be no way for him to know that our side is broken, unless we notify him as such. We notify him by sending this packet. How he deals with that is up to him.

RemoveSA ( Brunet.SecurityAssociation sa ) : void

Removes the specified SA from our database.

SARequestUpdate ( object o, EventArgs ea ) : void

When an SA wants to be updated, we instigate a new Security exchange.

StartSA ( PeerSecAssociation sa ) : void

This begins the SecurityAssociation exchange protocol over the specified SecurityAssociation.

비공개 메소드들

메소드 설명
PeerSecOverlord ( ) : Brunet

메소드 상세

CalculateCookie() 공개 메소드

We take in an object, take its hash code, concatenate it to our cookie, then sha hash the resulting value, creating the remote cookie.
public CalculateCookie ( object o ) : MemBlock
o object
리턴 MemBlock

CheckForSecurityAssociation() 공개 메소드

public CheckForSecurityAssociation ( ISender sender ) : Brunet.SecurityAssociation
sender ISender
리턴 Brunet.SecurityAssociation

CreateSecurityAssociation() 공개 메소드

This (idempotently) returns a new SecurityAssociation for the specified sender using the specified SPI and starts it if requested to.
public CreateSecurityAssociation ( ISender Sender, int SPI ) : PeerSecAssociation
Sender ISender
SPI int
리턴 PeerSecAssociation

CreateSecurityAssociation() 보호된 메소드

This (idempotently) returns a new SecurityAssociation for the specified sender using the specified SA.
protected CreateSecurityAssociation ( ISender Sender, int SPI, bool start ) : PeerSecAssociation
Sender ISender
SPI int
start bool
리턴 PeerSecAssociation

CreateSecurityAssociation() 공개 메소드

This (idempotently) returns a new SecurityAssociation for the specified sender using the default SPI and starts it if requested to.
public CreateSecurityAssociation ( ISender Sender ) : Brunet.SecurityAssociation
Sender ISender
리턴 Brunet.SecurityAssociation

HandleControl() 보호된 메소드

This is the control state machine. There are three paths in the state machine, iniator, receiver, and bidirectional. The bidirectional case occurs when two remote ISenders that are matched together initiate a handshake at the same time, otherwise the initiator /receiver pattern is followed. The high level overview for the states are: 1a) Send a Cookie 1b) Receive a Cookie which responds with a CookieResponse 2a) Receive a CookieResponse that contains a list of CAs, if you have a Certificate that supports one of the CAs send it along with a DHE and a list of your supported CAs in a DHEWithCertificateAndCAs. 2b) Receive a DHEWithCertificateAndCAs, verify the certificate and attempt to find a matching Certificate for the list of CAs, if you find one, finish the DHE handshake and send the certificate via a DHEWithCertificate 3a) Receive a DHEWithCertificate, verify the certificate and DHE and send a Confirm that you are ready to Verify the stack and start the system. 3b) Receive a Confirm, verify the entire stack and send a Confirm 4a)Receive a Confirm, verify the entire stack and all set to go
protected HandleControl ( MemBlock b, ISender return_path ) : void
b MemBlock
return_path ISender
리턴 void

HandleControlConfirm() 보호된 메소드

3b) Receive a Confirm, verify the entire stack and send a Confirm 4a)Receive a Confirm, verify the entire stack and all set to go
protected HandleControlConfirm ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void
sa PeerSecAssociation A security association that we wish to perform the /// specified control operation on.
scm SecurityControlMessage The received SecurityControlMessage.
scm_reply SecurityControlMessage A prepared reply message (with headers and such.
return_path ISender Where to send the result.
low_level_sender ISender We expect the return_path to not be an edge or /// some other type of "low level" sender, so this contains the parsed out value.
리턴 void

HandleControlCookie() 보호된 메소드

1b) Receive a Cookie which responds with a CookieResponse
protected HandleControlCookie ( PeerSecAssociation sa, MemBlock calc_cookie, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void
sa PeerSecAssociation A security association that we wish to perform the /// specified control operation on.
calc_cookie MemBlock Cookie value for the association sender.
scm SecurityControlMessage The received SecurityControlMessage.
scm_reply SecurityControlMessage A prepared reply message (with headers and such.
return_path ISender Where to send the result.
low_level_sender ISender We expect the return_path to not be an edge or /// some other type of "low level" sender, so this contains the parsed out value.
리턴 void

HandleControlCookieResponse() 보호된 메소드

2a) Receive a CookieResponse that contains a list of CAs, if you have a Certificate that supports one of the CAs send it along with a DHE and a list of your supported CAs in a DHEWithCertificateAndCAs.
protected HandleControlCookieResponse ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void
sa PeerSecAssociation A security association that we wish to perform the /// specified control operation on.
scm SecurityControlMessage The received SecurityControlMessage.
scm_reply SecurityControlMessage A prepared reply message (with headers and such.
return_path ISender Where to send the result.
low_level_sender ISender We expect the return_path to not be an edge or /// some other type of "low level" sender, so this contains the parsed out value.
리턴 void

HandleControlDHEWithCertificate() 보호된 메소드

3a) Receive a DHEWithCertificate, verify the certificate and DHE and send a Confirm that you are ready to Verify the stack and start the system.
protected HandleControlDHEWithCertificate ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void
sa PeerSecAssociation A security association that we wish to perform the /// specified control operation on.
scm SecurityControlMessage The received SecurityControlMessage.
scm_reply SecurityControlMessage A prepared reply message (with headers and such.
return_path ISender Where to send the result.
low_level_sender ISender We expect the return_path to not be an edge or /// some other type of "low level" sender, so this contains the parsed out value.
리턴 void

HandleControlDHEWithCertificateAndCAs() 보호된 메소드

2b) Receive a DHEWithCertificateAndCAs, verify the certificate and attempt to find a matching Certificate for the list of CAs, if you find one, finish the DHE handshake and send the certificate via a DHEWithCertificate
protected HandleControlDHEWithCertificateAndCAs ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void
sa PeerSecAssociation A security association that we wish to perform the /// specified control operation on.
scm SecurityControlMessage The received SecurityControlMessage.
scm_reply SecurityControlMessage A prepared reply message (with headers and such.
return_path ISender Where to send the result.
low_level_sender ISender We expect the return_path to not be an edge or /// some other type of "low level" sender, so this contains the parsed out value.
리턴 void

HandleControlNoSuchSA() 보호된 메소드

1a) Send a Cookie
protected HandleControlNoSuchSA ( PeerSecAssociation sa ) : void
sa PeerSecAssociation A security association that we wish to perform the /// specified control operation on.
리턴 void

HandleData() 보호된 메소드

This is SecureData that needs to get to an SA.
protected HandleData ( MemBlock b, ISender return_path ) : void
b MemBlock
return_path ISender
리턴 void

HandleData() 공개 메소드

All messages for the SecurityOverlord come through this loop. It demuxes between Security, SecureData, and SecureControl packets, while the remaining packets are left to the default handler.
public HandleData ( MemBlock data, ISender return_path, object state ) : void
data MemBlock
return_path ISender
state object
리턴 void

HandleError() 공개 메소드

If the request really failed, we'll have to close the SA.
public HandleError ( ReqrepManager man, int message_number, ReqrepManager err, ISender returnpath, object state ) : void
man ReqrepManager
message_number int
err ReqrepManager
returnpath ISender
state object
리턴 void

HandleReply() 공개 메소드

This better be a SecureControl message!
public HandleReply ( ReqrepManager man, ReqrepManager rt, int mid, PType prot, MemBlock payload, ISender returnpath, ReqrepManager statistics, object state ) : bool
man ReqrepManager
rt ReqrepManager
mid int
prot PType
payload MemBlock
returnpath ISender
statistics ReqrepManager
state object
리턴 bool

NoSuchSA() 보호된 메소드

After a restart of the Security system, one guy may think we still have an association and there will be no way for him to know that our side is broken, unless we notify him as such. We notify him by sending this packet. How he deals with that is up to him.
protected NoSuchSA ( int spi, ISender remote_sender ) : void
spi int
remote_sender ISender
리턴 void

PeerSecOverlord() 공개 메소드

public PeerSecOverlord ( RSACryptoServiceProvider rsa, Brunet.CertificateHandler ch, ReqrepManager rrman ) : Brunet
rsa System.Security.Cryptography.RSACryptoServiceProvider
ch Brunet.CertificateHandler
rrman ReqrepManager
리턴 Brunet

RemoveSA() 보호된 메소드

Removes the specified SA from our database.
protected RemoveSA ( Brunet.SecurityAssociation sa ) : void
sa Brunet.SecurityAssociation
리턴 void

SARequestUpdate() 보호된 메소드

When an SA wants to be updated, we instigate a new Security exchange.
protected SARequestUpdate ( object o, EventArgs ea ) : void
o object
ea System.EventArgs
리턴 void

StartSA() 보호된 메소드

This begins the SecurityAssociation exchange protocol over the specified SecurityAssociation.
protected StartSA ( PeerSecAssociation sa ) : void
sa PeerSecAssociation
리턴 void

프로퍼티 상세

CookieLength 공개적으로 정적으로 프로퍼티

The length used for the cookies.
public static int CookieLength
리턴 int

EmptyCookie 공개적으로 정적으로 프로퍼티

A quickly referenceable null (0) cookie.
public static MemBlock EmptyCookie
리턴 MemBlock

SecureControl 공개적으로 정적으로 프로퍼티

A control packet handled by the SecurityOverlord.
public static PType SecureControl
리턴 PType

SecureData 공개적으로 정적으로 프로퍼티

A data packet to be handled by the SecurityAssociations.
public static PType SecureData
리턴 PType

Security 공개적으로 정적으로 프로퍼티

Since we may receive packets from an external MultiSource, all security packets are prepended with this ptype.
public static PType Security
리턴 PType

Version 공개적으로 정적으로 프로퍼티

Security implementations version number.
public static int Version
리턴 int

_cookie 보호되어 있는 프로퍼티

protected byte[] _cookie
리턴 byte[]

_last_heartbeat 보호되어 있는 프로퍼티

protected DateTime,System _last_heartbeat
리턴 System.DateTime

_private_key_lock 보호되어 있는 프로퍼티

protected object _private_key_lock
리턴 object

_rand 보호되어 있는 프로퍼티

protected Random,System _rand
리턴 System.Random

_rrman 보호되어 있는 프로퍼티

protected ReqrepManager _rrman
리턴 ReqrepManager

_spi 보호되어 있는 프로퍼티

protected Dictionary> _spi
리턴 Dictionary>