Viewing File: /usr/lib/python2.7/site-packages/keyczar/keyczart.pyc

ó
NÑPc	@s:dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	dej
ddfdej
ddfdejddfdej
ddfdejddfdejddfgZ
dZd	efd
„ƒYZdefd„ƒYZed
ƒZedƒZedƒZedƒZedƒZedƒZedƒZied
6ed6ed6ed6ed6ed6ed6Zd„Zdefd„ƒYZedƒZedƒZedƒZedƒZedƒZ edƒZ!edƒZ"edƒZ#edƒZ$i	ed6ed6ed6ed6e d6e!d6e"d6e#d6e$d6Z%d „Z&dd!„Z'ddd"„Z(d#„Z)d$„Z*d%„Z+d&„Z,d'„Z-d(„Z.d)„Z/dd*d+„Z0d,„Z1dd-„Z2dd.„Z3d/„Z4e5d0kr6ej6e4ej7d1ƒƒndS(2su
Keyczart(ool) is a utility for creating and managing Keyczar keysets.

@author: arkajit.dey@gmail.com (Arkajit Dey)
iÿÿÿÿNtaessaes-cryptedthmactrsasrsa-signtdsat_NamecBseZd„Zd„ZRS(cCs
||_dS(N(tname(tselfR((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyt__init__,scCs|jS(N(R(R((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyt__str__/s(t__name__t
__module__RR(((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyR*s	tCommandcBseZdZRS(s$Enum representing keyczart commands.(R	R
t__doc__(((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyR2stcreatetaddkeytpubkeytpromotetdemotetrevoketgenkeycCs3yt|SWn tk
r.tjdƒ‚nXdS(NsIllegal command(tcommandstKeyErrorterrorstKeyczarError(tcmd((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyt
GetCommand@s
tFlagcBseZdZRS(s!Enum representing keyczart flags.(R	R
R(((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyRFstlocationRtsizetstatustpurposetdestinationtversiont
asymmetrictcryptercCs3yt|SWn tk
r.tjdƒ‚nXdS(NsUnknown flag(tflagsRRR(tflag((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pytGetFlagVs
cCs^tdkr*|dkr*tjdƒ‚nd}|tjkr®|dkrftj||tjƒ}q|j	ƒdkr“tj||tj
ƒ}qtj||tjƒ}n`|tjkrÿ|dkrätj||tj
ƒ}qtj||tj
ƒ}ntjdƒ‚tdk	r&|t_n4tj|ƒ}z|j|dtƒWd|jƒXdS(NsLocation missingRsMissing or unsupported purposet	overwrite(tmocktNoneRRtkeyinfotSIGN_AND_VERIFYtkeydatatKeyMetadatat	HMAC_SHA1tlowertRSA_PRIVtDSA_PRIVtDECRYPT_AND_ENCRYPTtAEStkmdtwriterstCreateWritert
WriteMetadatatFalsetClose(tlocRRR!R3twriter((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pytCreate\s(cCsHt||ƒ}|dkr$d}n|j||ƒt|||ƒdS(Niÿÿÿÿ(tCreateGenericKeyczarR(t
AddVersiontUpdateGenericKeyczar(R9RR"Rtczar((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pytAddKeyys
	cCsJtdkr*|dkr*tjdƒ‚nt|ƒ}|j|tƒdS(NsMust define destination(R'R(RRR<tPublicKeyExport(R9tdestR?((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pytPubKey€scCsHt|ƒ}|dkr*tjdƒ‚n|j|ƒt||ƒdS(NisMissing version(R<RRtPromoteR>(R9tnumR?((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyRD†s

cCsHt|ƒ}|dkr*tjdƒ‚n|j|ƒt||ƒdS(NisMissing version(R<RRtDemoteR>(R9RER?((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyRFs

cCs’t|ƒ}|dkr*tjdƒ‚n|j|ƒt||ƒtdk	r`tj|ƒn.tj	|ƒ}z|j
|ƒWd|jƒXdS(NisMissing version(R<RRtRevokeR>R'R(t	RemoveKeyR4R5tRemoveR8(R9RER?R:((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyRG”s

cCstjj|ƒS(s,Helper to create a Crypter for the location.(tkeyczartCryptertRead(R((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyt_CreateCrypter£scCsFdGHxßtD]×\}}}}dGHtjj||ƒ}|r\ttjj||ƒƒ}nt|ƒt|d||ƒt|tj	|ƒt
||tjj|dƒ|ƒt|tj	|ƒt
||tjj|dƒ|ƒqWdGHxNdD]F}dGHtjj||ƒ}tjj||d	ƒ}t||ƒqóWd
GHdS(NsGenerating private key sets...t.tTests1.outs2.outsExporting public key sets...Rsrsa-signs.publicsDone!(Rsrsa-sign(tKEYSETStostpathtjoinRMtCleanR;R@R)tPRIMARYtUseKeyRC(R9RRR!R"tdir_pathRB((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyt	GenKeySet§s&
"&
cCsUxNtj|ƒD]=}tjj||ƒ}tjj|ƒstj|ƒqqWdS(N(RQtlistdirRRRStisdirtremove(t	directorytfilenameRR((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyRT½ssThis is some test datacCsªtj|ƒ}z‰d}|r3tj||ƒ}n|tjkr]tj|ƒj|ƒ}n*|tjkr‡tj	|ƒj
|ƒ}ntj||ƒWd|j
ƒXdS(Nt(treaderstCreateReadertEncryptedReaderR)R1RJRKtEncryptR*tSignertSigntutilt	WriteFileR8(RR9RBR"tmsgtreadertanswer((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyRVÃscCs	dGHdS(NsâUsage: "Keyczart command flags"
  Commands: create addkey pubkey promote demote revoke
Flags: location name size status purpose destination version asymmetric crypter
Command Usage:
create --location=/path/to/keys --purpose=(crypt|sign) [--name="A name"] [--asymmetric=(dsa|rsa)]
  Creates a new, empty key set in the given location.
  This key set must have a purpose of either "crypt" or "sign"
  and may optionally be given a name. The optional asymmetric 
  flag will generate a public key set of the given algorithm.
  The "dsa" asymmetric value is valid only for sets with "sign" purpose.
  with the given purpose.
addkey --location=/path/to/keys [--status=(active|primary)] [--size=size] [--crypter=crypterLocation]
  Adds a new key to an existing key set. Optionally
  specify a purpose, which is active by default. Optionally
  specify a key size in bits. Also optionally specify the
  location of a set of crypting keys, which will be used to
  encrypt this key set.
pubkey --location=/path/to/keys --destination=/destination
  Extracts public keys from a given key set and writes them
  to the destination. The "pubkey" command Only works for
  key sets that were created with the "--asymmetric" flag.
promote --location=/path/to/keys --version=versionNumber
  Promotes the status of the given key version in the given 
  location. Active keys are promoted to primary (which demotes 
  any existing primary key to active). Keys scheduled for 
  revocation are promoted to be active.
demote --location=/path/to/keys --version=versionNumber
  Demotes the status of the given key version in the given
  location. Primary keys are demoted to active. Active keys
  are scheduled for revocation.
revoke --location=/path/to/keys --version=versionNumber
  Revokes the key of the given version number.
  This key must have been scheduled for revocation by the
  promote command. WARNING: The key will be destroyed.

Optional flags are in [brackets]. The notation (a|b|c) means "a", "b", and "c"
are the valid choices((((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pytUsageÑs%cCstdk	rtjtƒS|dkr7tjdƒ‚nUd}tj|ƒ}z.|rjtj||ƒ}ntj|ƒ}Wd|j	ƒX|SdS(Ns
Need location(
R'R(RJtGenericKeyczarRRR_R`RaR8(R9R"tgenericRh((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyR<øs
cCs€tdk	rK|jt_xa|jD]"}tj|j|j|ƒƒq"Wn1tj	|ƒ}z|j
||ƒWd|jƒXdS(N(R'R(tmetadataR3tversionstSetKeytversion_numbertGetKeyR4R5tWriteR8(R?R9t	encryptertvR:((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyR>s#cCsst|ƒdkrtƒnSt|dƒ}i}xs|D]k}|jdƒr9|d}y)|jdƒ\}}||t|ƒ<Wq¤tk
r dGHtƒq¤Xq9q9Wy4t|jt	dƒƒ}t|jt
dƒƒ}Wntk
rûdGHtƒnX|jtƒ}|tkrnit
jd6t
jd	6j|jtƒƒ}	t||jtd
ƒ|	|jtƒƒn|tkrÖt
j|jtdƒjƒƒ}
t|krºt|tƒ}nd}t||
||ƒn™|tkrût||jtƒƒnt|tkrt ||ƒnX|t!kr3t"||ƒn<|t#krOt$||ƒn |t%krht&|ƒntƒdS(Nis--it=sFlags incorrectly formattediÿÿÿÿs)Size and version flags require an integertcrypttsignROtACTIVE('tlenRjRt
startswithtsplitR%t
ValueErrortinttgettVERSIONtSIZEtLOCATIONtCREATER)R1R*tPURPOSER;tNAMEt
ASYMMETRICtADDKEYt	GetStatustSTATUStuppertCRYPTERRMR(R@tPUBKEYRCtDESTINATIONtPROMOTERDtDEMOTERFtREVOKERGtGENKEYRX(targvRR#targR$tvalR RR9RRR"((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pytmainsR





+!
t__main__i(8RRQtsysRRJR+R)R_R4ReR1R(R*RPR'tobjectRRR‚R†R‹RRŽRRRRRRR„R€RˆRƒRŒRR…RŠR#R%R;R@RCRDRFRGRMRXRTRVRjR<R>R”R	texitR‘(((s4/usr/lib/python2.7/site-packages/keyczar/keyczart.pyt<module>sv
										'	2
Back to Directory File Manager